Skip to content

CLN: fix C408 #38138 #38320

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

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ def factorize(self, na_sentinel: int = -1) -> Tuple[np.ndarray, ExtensionArray]:
@Substitution(klass="ExtensionArray")
@Appender(_extension_array_shared_docs["repeat"])
def repeat(self, repeats, axis=None):
nv.validate_repeat(tuple(), {"axis": axis})
nv.validate_repeat((), {"axis": axis})
ind = np.arange(len(self)).repeat(repeats)
return self.take(ind)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/computation/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numexpr as ne

_TEST_MODE = None
_TEST_RESULT: List[bool] = list()
_TEST_RESULT: List[bool] = []
USE_NUMEXPR = NUMEXPR_INSTALLED
_evaluate = None
_where = None
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PandasExtensionDtype(ExtensionDtype):
subdtype = None
str: str_type
num = 100
shape: Tuple[int, ...] = tuple()
shape: Tuple[int, ...] = ()
itemsize = 8
base = None
isbuiltin = 0
Expand Down
16 changes: 8 additions & 8 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,7 @@ class max_speed
stacklevel=2,
)

nv.validate_take(tuple(), kwargs)
nv.validate_take((), kwargs)

self._consolidate_inplace()

Expand Down Expand Up @@ -10557,7 +10557,7 @@ def _agg_by_level(self, name, axis=0, level=0, skipna=True, **kwargs):
def _logical_func(
self, name: str, func, axis=0, bool_only=None, skipna=True, level=None, **kwargs
):
nv.validate_logical_func(tuple(), kwargs, fname=name)
nv.validate_logical_func((), kwargs, fname=name)
if level is not None:
if bool_only is not None:
raise NotImplementedError(
Expand Down Expand Up @@ -10644,7 +10644,7 @@ def _stat_function_ddof(
numeric_only=None,
**kwargs,
):
nv.validate_stat_ddof_func(tuple(), kwargs, fname=name)
nv.validate_stat_ddof_func((), kwargs, fname=name)
if skipna is None:
skipna = True
if axis is None:
Expand Down Expand Up @@ -10690,9 +10690,9 @@ def _stat_function(
**kwargs,
):
if name == "median":
nv.validate_median(tuple(), kwargs)
nv.validate_median((), kwargs)
else:
nv.validate_stat_func(tuple(), kwargs, fname=name)
nv.validate_stat_func((), kwargs, fname=name)
if skipna is None:
skipna = True
if axis is None:
Expand Down Expand Up @@ -10748,11 +10748,11 @@ def _min_count_stat_function(
**kwargs,
):
if name == "sum":
nv.validate_sum(tuple(), kwargs)
nv.validate_sum((), kwargs)
elif name == "prod":
nv.validate_prod(tuple(), kwargs)
nv.validate_prod((), kwargs)
else:
nv.validate_stat_func(tuple(), kwargs, fname=name)
nv.validate_stat_func((), kwargs, fname=name)
if skipna is None:
skipna = True
if axis is None:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def astype(self, dtype, copy=True):
@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs):
if kwargs:
nv.validate_take(tuple(), kwargs)
nv.validate_take((), kwargs)
indices = ensure_platform_int(indices)
allow_fill = self._maybe_disallow_fill(allow_fill, fill_value, indices)

Expand Down Expand Up @@ -817,7 +817,7 @@ def _maybe_disallow_fill(self, allow_fill: bool, fill_value, indices) -> bool:
@Appender(_index_shared_docs["repeat"] % _index_doc_kwargs)
def repeat(self, repeats, axis=None):
repeats = ensure_platform_int(repeats)
nv.validate_repeat(tuple(), {"axis": axis})
nv.validate_repeat((), {"axis": axis})
return self._shallow_copy(self._values.repeat(repeats))

# --------------------------------------------------------------------
Expand Down
56 changes: 28 additions & 28 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@
_index_doc_kwargs = dict(ibase._index_doc_kwargs)

_index_doc_kwargs.update(
dict(
klass="IntervalIndex",
qualname="IntervalIndex",
target_klass="IntervalIndex or list of Intervals",
name=textwrap.dedent(
{
"klass": "IntervalIndex",
"qualname": "IntervalIndex",
"target_klass": "IntervalIndex or list of Intervals",
"name": textwrap.dedent(
"""\
name : object, optional
Name to be stored in the index.
"""
),
)
}
)


Expand Down Expand Up @@ -141,14 +141,14 @@ def wrapped(self, other, sort=False):

@Appender(
_interval_shared_docs["class"]
% dict(
klass="IntervalIndex",
summary="Immutable index of intervals that are closed on the same side.",
name=_index_doc_kwargs["name"],
versionadded="0.20.0",
extra_attributes="is_overlapping\nvalues\n",
extra_methods="",
examples=textwrap.dedent(
% {
"klass": "IntervalIndex",
"summary": "Immutable index of intervals that are closed on the same side.",
"name": _index_doc_kwargs["name"],
"versionadded": "0.20.0",
"extra_attributes": "is_overlapping\nvalues\n",
"extra_methods": "",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -168,7 +168,7 @@ def wrapped(self, other, sort=False):
mentioned constructor methods.
"""
),
)
}
)
@inherit_names(["set_closed", "to_tuples"], IntervalArray, wrap=True)
@inherit_names(["__array__", "overlaps", "contains"], IntervalArray)
Expand Down Expand Up @@ -234,9 +234,9 @@ def _simple_new(cls, array: IntervalArray, name: Label = None):
@classmethod
@Appender(
_interval_shared_docs["from_breaks"]
% dict(
klass="IntervalIndex",
examples=textwrap.dedent(
% {
"klass": "IntervalIndex",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -246,7 +246,7 @@ def _simple_new(cls, array: IntervalArray, name: Label = None):
dtype='interval[int64]')
"""
),
)
}
)
def from_breaks(
cls, breaks, closed: str = "right", name=None, copy: bool = False, dtype=None
Expand All @@ -260,9 +260,9 @@ def from_breaks(
@classmethod
@Appender(
_interval_shared_docs["from_arrays"]
% dict(
klass="IntervalIndex",
examples=textwrap.dedent(
% {
"klass": "IntervalIndex",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -272,7 +272,7 @@ def from_breaks(
dtype='interval[int64]')
"""
),
)
}
)
def from_arrays(
cls,
Expand All @@ -292,9 +292,9 @@ def from_arrays(
@classmethod
@Appender(
_interval_shared_docs["from_tuples"]
% dict(
klass="IntervalIndex",
examples=textwrap.dedent(
% {
"klass": "IntervalIndex",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -304,7 +304,7 @@ def from_arrays(
dtype='interval[int64]')
"""
),
)
}
)
def from_tuples(
cls, data, closed: str = "right", name=None, copy: bool = False, dtype=None
Expand Down Expand Up @@ -360,7 +360,7 @@ def __array_wrap__(self, result, context=None):
return result

def __reduce__(self):
d = dict(left=self.left, right=self.right)
d = {"left": self.left, "right": self.right}
d.update(self._get_attributes_dict())
return _new_IntervalIndex, (type(self), d), None

Expand Down
20 changes: 10 additions & 10 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

_index_doc_kwargs = dict(ibase._index_doc_kwargs)
_index_doc_kwargs.update(
dict(klass="MultiIndex", target_klass="MultiIndex or list of tuples")
{"klass": "MultiIndex", "target_klass": "MultiIndex or list of tuples"}
)


Expand Down Expand Up @@ -2007,12 +2007,12 @@ def remove_unused_levels(self):

def __reduce__(self):
"""Necessary for making this object picklable"""
d = dict(
levels=list(self.levels),
codes=list(self.codes),
sortorder=self.sortorder,
names=list(self.names),
)
d = {
"levels": list(self.levels),
"codes": list(self.codes),
"sortorder": self.sortorder,
"names": list(self.names),
}
return ibase._new_Index, (type(self), d), None

# --------------------------------------------------------------------
Expand Down Expand Up @@ -2052,7 +2052,7 @@ def __getitem__(self, key):

@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs):
nv.validate_take(tuple(), kwargs)
nv.validate_take((), kwargs)
indices = ensure_platform_int(indices)

# only fill if we are passing a non-None fill_value
Expand Down Expand Up @@ -2116,7 +2116,7 @@ def argsort(self, *args, **kwargs) -> np.ndarray:

@Appender(_index_shared_docs["repeat"] % _index_doc_kwargs)
def repeat(self, repeats, axis=None):
nv.validate_repeat(tuple(), dict(axis=axis))
nv.validate_repeat((), {"axis": axis})
repeats = ensure_platform_int(repeats)
return MultiIndex(
levels=self.levels,
Expand Down Expand Up @@ -3353,7 +3353,7 @@ def _reorder_indexer(
return indexer

n = len(self)
keys: Tuple[np.ndarray, ...] = tuple()
keys: Tuple[np.ndarray, ...] = ()
# For each level of the sequence in seq, map the level codes with the
# order they appears in a list-like sequence
# This mapping is then use to reorder the indexer
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def _init_dict(self, data, index=None, dtype=None):
values = na_value_for_dtype(dtype)
keys = index
else:
keys, values = tuple(), []
keys, values = (), []

# Input is now list-like, so rely on "standard" construction:

Expand Down Expand Up @@ -775,7 +775,7 @@ def take(self, indices, axis=0, is_copy=None, **kwargs) -> "Series":
FutureWarning,
stacklevel=2,
)
nv.validate_take(tuple(), kwargs)
nv.validate_take((), kwargs)

indices = ensure_platform_int(indices)
new_index = self.index.take(indices)
Expand Down Expand Up @@ -1114,7 +1114,7 @@ def repeat(self, repeats, axis=None) -> "Series":
2 c
dtype: object
"""
nv.validate_repeat(tuple(), {"axis": axis})
nv.validate_repeat((), {"axis": axis})
new_index = self.index.repeat(repeats)
new_values = self._values.repeat(repeats)
return self._constructor(new_values, index=new_index).__finalize__(
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def coerce(request):
([1], True, "list"),
([], True, "list-empty"),
((1,), True, "tuple"),
(tuple(), True, "tuple-empty"),
((), True, "tuple-empty"),
({"a": 1}, True, "dict"),
({}, True, "dict-empty"),
({"a", 1}, "set", "set"),
Expand Down Expand Up @@ -161,7 +161,7 @@ class DtypeList(list):
assert inference.is_array_like(DtypeList())

assert not inference.is_array_like([1, 2, 3])
assert not inference.is_array_like(tuple())
assert not inference.is_array_like(())
assert not inference.is_array_like("foo")
assert not inference.is_array_like(123)

Expand Down Expand Up @@ -326,7 +326,7 @@ class UnhashableClass2:
def __hash__(self):
raise TypeError("Not hashable")

hashable = (1, 3.14, np.float64(3.14), "a", tuple(), (1,), HashableClass())
hashable = (1, 3.14, np.float64(3.14), "a", (), (1,), HashableClass())
not_hashable = ([], UnhashableClass1())
abc_hashable_not_really_hashable = (([],), UnhashableClass2())

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_to_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def test_to_records_with_categorical(self):
),
# Invalid dype values.
(
{"index": False, "column_dtypes": list()},
{"index": False, "column_dtypes": []},
(ValueError, "Invalid dtype \\[\\] specified for column A"),
),
(
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/groupby/transform/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_transform_axis_1(transformation_func):
# GH 36308
if transformation_func == "tshift":
pytest.xfail("tshift is deprecated")
args = ("ffill",) if transformation_func == "fillna" else tuple()
args = ("ffill",) if transformation_func == "fillna" else ()

df = DataFrame({"a": [1, 2], "b": [3, 4], "c": [5, 6]}, index=["x", "y"])
result = df.groupby([0, 0, 1], axis=1).transform(transformation_func, *args)
Expand Down Expand Up @@ -803,7 +803,7 @@ def test_group_fill_methods(
keys = ["a", "b"] * len(vals)

def interweave(list_obj):
temp = list()
temp = []
for x in list_obj:
temp.extend([x, x])

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2908,11 +2908,11 @@ def test_too_long(self):
with pd.option_context("display.precision", 4):
# need both a number > 1e6 and something that normally formats to
# having length > display.precision + 6
df = DataFrame(dict(x=[12345.6789]))
df = DataFrame({"x": [12345.6789]})
assert str(df) == " x\n0 12345.6789"
df = DataFrame(dict(x=[2e6]))
df = DataFrame({"x": [2e6]})
assert str(df) == " x\n0 2000000.0"
df = DataFrame(dict(x=[12345.6789, 2e6]))
df = DataFrame({"x": [12345.6789, 2e6]})
assert str(df) == " x\n0 1.2346e+04\n1 2.0000e+06"


Expand Down
Loading