Skip to content

Commit 25846e9

Browse files
authored
CLN: fix flake8 C408 part 2 (#38116)
1 parent 1c26b1c commit 25846e9

File tree

76 files changed

+271
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+271
-255
lines changed

pandas/_testing.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,15 +2167,15 @@ def makeCustomIndex(
21672167
names = [names]
21682168

21692169
# specific 1D index type requested?
2170-
idx_func = dict(
2171-
i=makeIntIndex,
2172-
f=makeFloatIndex,
2173-
s=makeStringIndex,
2174-
u=makeUnicodeIndex,
2175-
dt=makeDateIndex,
2176-
td=makeTimedeltaIndex,
2177-
p=makePeriodIndex,
2178-
).get(idx_type)
2170+
idx_func = {
2171+
"i": makeIntIndex,
2172+
"f": makeFloatIndex,
2173+
"s": makeStringIndex,
2174+
"u": makeUnicodeIndex,
2175+
"dt": makeDateIndex,
2176+
"td": makeTimedeltaIndex,
2177+
"p": makePeriodIndex,
2178+
}.get(idx_type)
21792179
if idx_func:
21802180
# pandas\_testing.py:2120: error: Cannot call function of unknown type
21812181
idx = idx_func(nentries) # type: ignore[operator]

pandas/compat/numpy/function.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __call__(
7171
raise ValueError(f"invalid validation method '{method}'")
7272

7373

74-
ARGMINMAX_DEFAULTS = dict(out=None)
74+
ARGMINMAX_DEFAULTS = {"out": None}
7575
validate_argmin = CompatValidator(
7676
ARGMINMAX_DEFAULTS, fname="argmin", method="both", max_fname_arg_count=1
7777
)
@@ -151,7 +151,7 @@ def validate_argsort_with_ascending(ascending, args, kwargs):
151151
return ascending
152152

153153

154-
CLIP_DEFAULTS: Dict[str, Any] = dict(out=None)
154+
CLIP_DEFAULTS: Dict[str, Any] = {"out": None}
155155
validate_clip = CompatValidator(
156156
CLIP_DEFAULTS, fname="clip", method="both", max_fname_arg_count=3
157157
)
@@ -208,28 +208,28 @@ def validate_cum_func_with_skipna(skipna, args, kwargs, name):
208208
ALLANY_DEFAULTS, fname="any", method="both", max_fname_arg_count=1
209209
)
210210

211-
LOGICAL_FUNC_DEFAULTS = dict(out=None, keepdims=False)
211+
LOGICAL_FUNC_DEFAULTS = {"out": None, "keepdims": False}
212212
validate_logical_func = CompatValidator(LOGICAL_FUNC_DEFAULTS, method="kwargs")
213213

214-
MINMAX_DEFAULTS = dict(axis=None, out=None, keepdims=False)
214+
MINMAX_DEFAULTS = {"axis": None, "out": None, "keepdims": False}
215215
validate_min = CompatValidator(
216216
MINMAX_DEFAULTS, fname="min", method="both", max_fname_arg_count=1
217217
)
218218
validate_max = CompatValidator(
219219
MINMAX_DEFAULTS, fname="max", method="both", max_fname_arg_count=1
220220
)
221221

222-
RESHAPE_DEFAULTS: Dict[str, str] = dict(order="C")
222+
RESHAPE_DEFAULTS: Dict[str, str] = {"order": "C"}
223223
validate_reshape = CompatValidator(
224224
RESHAPE_DEFAULTS, fname="reshape", method="both", max_fname_arg_count=1
225225
)
226226

227-
REPEAT_DEFAULTS: Dict[str, Any] = dict(axis=None)
227+
REPEAT_DEFAULTS: Dict[str, Any] = {"axis": None}
228228
validate_repeat = CompatValidator(
229229
REPEAT_DEFAULTS, fname="repeat", method="both", max_fname_arg_count=1
230230
)
231231

232-
ROUND_DEFAULTS: Dict[str, Any] = dict(out=None)
232+
ROUND_DEFAULTS: Dict[str, Any] = {"out": None}
233233
validate_round = CompatValidator(
234234
ROUND_DEFAULTS, fname="round", method="both", max_fname_arg_count=1
235235
)
@@ -300,7 +300,7 @@ def validate_take_with_convert(convert, args, kwargs):
300300
return convert
301301

302302

303-
TRANSPOSE_DEFAULTS = dict(axes=None)
303+
TRANSPOSE_DEFAULTS = {"axes": None}
304304
validate_transpose = CompatValidator(
305305
TRANSPOSE_DEFAULTS, fname="transpose", method="both", max_fname_arg_count=0
306306
)

pandas/core/arrays/_mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def repeat(
162162
--------
163163
numpy.ndarray.repeat
164164
"""
165-
nv.validate_repeat(tuple(), dict(axis=axis))
165+
nv.validate_repeat((), {"axis": axis})
166166
new_data = self._ndarray.repeat(repeats, axis=axis)
167167
return self._from_backing_data(new_data)
168168

pandas/core/arrays/sparse/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
SparseArrayT = TypeVar("SparseArrayT", bound="SparseArray")
6060

61-
_sparray_doc_kwargs = dict(klass="SparseArray")
61+
_sparray_doc_kwargs = {"klass": "SparseArray"}
6262

6363

6464
def _get_fill(arr: "SparseArray") -> np.ndarray:

pandas/core/arrays/timedeltas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def sum(
373373
min_count: int = 0,
374374
):
375375
nv.validate_sum(
376-
(), dict(dtype=dtype, out=out, keepdims=keepdims, initial=initial)
376+
(), {"dtype": dtype, "out": out, "keepdims": keepdims, "initial": initial}
377377
)
378378

379379
result = nanops.nansum(
@@ -391,7 +391,7 @@ def std(
391391
skipna: bool = True,
392392
):
393393
nv.validate_stat_ddof_func(
394-
(), dict(dtype=dtype, out=out, keepdims=keepdims), fname="std"
394+
(), {"dtype": dtype, "out": out, "keepdims": keepdims}, fname="std"
395395
)
396396

397397
result = nanops.nanstd(self._ndarray, axis=axis, skipna=skipna, ddof=ddof)

pandas/core/base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
if TYPE_CHECKING:
4747
from pandas import Categorical
4848

49-
_shared_docs: Dict[str, str] = dict()
50-
_indexops_doc_kwargs = dict(
51-
klass="IndexOpsMixin",
52-
inplace="",
53-
unique="IndexOpsMixin",
54-
duplicated="IndexOpsMixin",
55-
)
49+
_shared_docs: Dict[str, str] = {}
50+
_indexops_doc_kwargs = {
51+
"klass": "IndexOpsMixin",
52+
"inplace": "",
53+
"unique": "IndexOpsMixin",
54+
"duplicated": "IndexOpsMixin",
55+
}
5656

5757
_T = TypeVar("_T", bound="IndexOpsMixin")
5858

pandas/core/dtypes/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def create_pandas_abc_type(name, attr, comp):
1818
def _check(cls, inst) -> bool:
1919
return getattr(inst, attr, "_typ") in comp
2020

21-
dct = dict(__instancecheck__=_check, __subclasscheck__=_check)
21+
dct = {"__instancecheck__": _check, "__subclasscheck__": _check}
2222
meta = type("ABCBase", (type,), dct)
23-
return meta(name, tuple(), dct)
23+
return meta(name, (), dct)
2424

2525

2626
ABCInt64Index = create_pandas_abc_type("ABCInt64Index", "_typ", ("int64index",))

pandas/core/groupby/groupby.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ class providing the base-class of operations.
8585
to each row or column of a DataFrame.
8686
"""
8787

88-
_apply_docs = dict(
89-
template="""
88+
_apply_docs = {
89+
"template": """
9090
Apply function `func` group-wise and combine the results together.
9191
9292
The function passed to `apply` must take a {input} as its first
@@ -123,7 +123,7 @@ class providing the base-class of operations.
123123
Series.apply : Apply a function to a Series.
124124
DataFrame.apply : Apply a function to each row or column of a DataFrame.
125125
""",
126-
dataframe_examples="""
126+
"dataframe_examples": """
127127
>>> df = pd.DataFrame({'A': 'a a b'.split(),
128128
'B': [1,2,3],
129129
'C': [4,6, 5]})
@@ -163,7 +163,7 @@ class providing the base-class of operations.
163163
b 2
164164
dtype: int64
165165
""",
166-
series_examples="""
166+
"series_examples": """
167167
>>> s = pd.Series([0, 1, 2], index='a a b'.split())
168168
>>> g = s.groupby(s.index)
169169
@@ -202,7 +202,7 @@ class providing the base-class of operations.
202202
--------
203203
{examples}
204204
""",
205-
)
205+
}
206206

207207
_groupby_agg_method_template = """
208208
Compute {fname} of group values.

pandas/core/indexes/category.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import pandas.core.missing as missing
2828

2929
_index_doc_kwargs = dict(ibase._index_doc_kwargs)
30-
_index_doc_kwargs.update(dict(target_klass="CategoricalIndex"))
30+
_index_doc_kwargs.update({"target_klass": "CategoricalIndex"})
3131

3232

3333
@inherit_names(

pandas/core/indexes/datetimelike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def __contains__(self, key: Any) -> bool:
200200

201201
@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
202202
def take(self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs):
203-
nv.validate_take(tuple(), kwargs)
203+
nv.validate_take((), kwargs)
204204
indices = np.asarray(indices, dtype=np.intp)
205205

206206
maybe_slice = lib.maybe_indices_to_slice(indices, len(self))

0 commit comments

Comments
 (0)