-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unpin pycodestyle #25789
Unpin pycodestyle #25789
Changes from 9 commits
bb63bdf
313ac3e
ff1b536
f8979af
38e0bcf
2549742
324bdc9
7b3e836
9d4ece7
739bcab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
without warning. | ||
""" | ||
import operator | ||
from typing import Any, Callable, Optional, Sequence, Tuple, Union | ||
|
||
import numpy as np | ||
|
||
|
@@ -15,6 +16,7 @@ | |
from pandas.util._decorators import Appender, Substitution | ||
|
||
from pandas.core.dtypes.common import is_list_like | ||
from pandas.core.dtypes.dtypes import ExtensionDtype | ||
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries | ||
from pandas.core.dtypes.missing import isna | ||
|
||
|
@@ -365,7 +367,7 @@ def isna(self): | |
raise AbstractMethodError(self) | ||
|
||
def _values_for_argsort(self): | ||
# type: () -> ndarray | ||
# type: () -> np.ndarray | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can switch to the py3 style now i think (here or later) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea planning to do later to minimize diff There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great |
||
""" | ||
Return values for sorting. | ||
|
||
|
@@ -597,7 +599,7 @@ def searchsorted(self, value, side="left", sorter=None): | |
return arr.searchsorted(value, side=side, sorter=sorter) | ||
|
||
def _values_for_factorize(self): | ||
# type: () -> Tuple[ndarray, Any] | ||
# type: () -> Tuple[np.ndarray, Any] | ||
""" | ||
Return an array and missing value suitable for factorization. | ||
|
||
|
@@ -622,7 +624,7 @@ def _values_for_factorize(self): | |
return self.astype(object), np.nan | ||
|
||
def factorize(self, na_sentinel=-1): | ||
# type: (int) -> Tuple[ndarray, ExtensionArray] | ||
# type: (int) -> Tuple[np.ndarray, ExtensionArray] | ||
""" | ||
Encode the extension array as an enumerated type. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,11 @@ | |
from datetime import datetime, timedelta | ||
import operator | ||
import warnings | ||
from typing import Any, Sequence, Tuple, Union | ||
|
||
import numpy as np | ||
|
||
from pandas._libs import NaT, algos, iNaT, lib | ||
from pandas._libs import NaT, NaTType, algos, iNaT, lib, Timestamp | ||
from pandas._libs.tslibs.period import ( | ||
DIFFERENT_FREQ, IncompatibleFrequency, Period) | ||
from pandas._libs.tslibs.timedeltas import Timedelta, delta_to_nanoseconds | ||
|
@@ -350,7 +351,7 @@ def __iter__(self): | |
|
||
@property | ||
def asi8(self): | ||
# type: () -> ndarray | ||
# type: () -> np.ndarray | ||
""" | ||
Integer representation of the values. | ||
|
||
|
@@ -461,10 +462,10 @@ def __getitem__(self, key): | |
def __setitem__( | ||
self, | ||
key, # type: Union[int, Sequence[int], Sequence[bool], slice] | ||
value, # type: Union[NaTType, Scalar, Sequence[Scalar]] | ||
value, # type: Union[NaTType, Any, Sequence[Any]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does Any not encompan NaTType here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Valid question. I mostly changed this to get it to pass since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no it would fail for that. What we need is a type that is an allowed datetime value, e.g: string, datetime / Timestamp, NaT). These can of course be done later, but should start setting up a pandas.typing i think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yah, I'd rather have an import from pandas.typing and avoid imports that aren't "really" used (i.e. NaTType). |
||
): | ||
# type: (...) -> None | ||
# I'm fudging the types a bit here. The "Scalar" above really depends | ||
# I'm fudging the types a bit here. "Any" above really depends | ||
# on type(self). For PeriodArray, it's Period (or stuff coercible | ||
# to a period in from_sequence). For DatetimeArray, it's Timestamp... | ||
# I don't know if mypy can do that, possibly with Generics. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
from datetime import timedelta | ||
import operator | ||
from typing import Any, Callable, Optional, Sequence, Union | ||
|
||
import numpy as np | ||
|
||
from pandas._libs.tslibs import ( | ||
NaT, frequencies as libfrequencies, iNaT, period as libperiod) | ||
NaT, NaTType, frequencies as libfrequencies, iNaT, period as libperiod) | ||
from pandas._libs.tslibs.fields import isleapyear_arr | ||
from pandas._libs.tslibs.period import ( | ||
DIFFERENT_FREQ, IncompatibleFrequency, Period, get_period_field_arr, | ||
|
@@ -23,7 +24,7 @@ | |
from pandas.core.dtypes.missing import isna, notna | ||
|
||
import pandas.core.algorithms as algos | ||
from pandas.core.arrays import datetimelike as dtl | ||
from pandas.core.arrays import datetimelike as dtl, ExtensionArray | ||
import pandas.core.common as com | ||
|
||
from pandas.tseries import frequencies | ||
|
@@ -536,11 +537,14 @@ def _sub_period(self, other): | |
@Appender(dtl.DatetimeLikeArrayMixin._addsub_int_array.__doc__) | ||
def _addsub_int_array( | ||
self, | ||
other, # type: Union[Index, ExtensionArray, np.ndarray[int]] | ||
op # type: Callable[Any, Any] | ||
other, # type: Union[ExtensionArray, np.ndarray[int]] | ||
op # type: Callable[Any, Any] | ||
): | ||
# type: (...) -> PeriodArray | ||
|
||
# TODO: ABCIndexClass is a valid type for other but had to be excluded | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment explains it, but just to clarify this PR doesn't necessarily check that comments are correct as much as gets them to pass linting. I figure it makes sense to validate the comments themselves when moving over to Py3 syntax, so this was the quick way of getting this to pass |
||
# due to length of Py2 compatability comment; add back in once migrated | ||
# to Py3 syntax | ||
assert op in [operator.add, operator.sub] | ||
if op is operator.sub: | ||
other = -other | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,7 +440,6 @@ def _chk_truncate(self): | |
max_rows = self.max_rows | ||
|
||
if max_cols == 0 or max_rows == 0: # assume we are in the terminal | ||
# (why else = 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hanging comment was causing a lint error. I figured it didn't add much so easier to remove than reword |
||
(w, h) = get_terminal_size() | ||
self.w = w | ||
self.h = h | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,7 +201,8 @@ def test_set_index_pass_arrays_duplicate(self, frame_of_index_cols, drop, | |
# need to adapt first drop for case that both keys are 'A' -- | ||
# cannot drop the same column twice; | ||
# use "is" because == would give ambiguous Boolean error for containers | ||
first_drop = False if (keys[0] is 'A' and keys[1] is 'A') else drop | ||
first_drop = False if ( | ||
keys[0] is 'A' and keys[1] is 'A') else drop # noqa: F632 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F632 is ignored because it calls out using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC interning of short strings is a CPython implementation detail. Are we sure we want to rely on that? |
||
|
||
# to test against already-tested behaviour, we add sequentially, | ||
# hence second append always True; must wrap keys in list, otherwise | ||
|
@@ -1272,7 +1273,7 @@ def test_rename_axis_style_raises(self): | |
df.rename(id, mapper=id) | ||
|
||
def test_reindex_api_equivalence(self): | ||
# equivalence of the labels/axis and index/columns API's | ||
# equivalence of the labels/axis and index/columns API's | ||
df = DataFrame([[1, 2, 3], [3, 4, 5], [5, 6, 7]], | ||
index=['a', 'b', 'c'], | ||
columns=['d', 'e', 'f']) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
|
||
def test_apply_issues(): | ||
# GH 5788 | ||
# GH 5788 | ||
|
||
s = """2011.05.16,00:00,1.40893 | ||
2011.05.16,01:00,1.40760 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if there's any objection to doing this, but if we didn't want to expose this would need to update type comments @jbrockmendel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the motivation here? I wouldn't want to expose this ideally. But its explicitly private so not really harmful.