Skip to content

Commit fb5e57f

Browse files
authored
New dict call fixings #38138 (#38298)
1 parent 5011a37 commit fb5e57f

File tree

5 files changed

+51
-51
lines changed

5 files changed

+51
-51
lines changed

pandas/core/arrays/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from pandas.core.missing import get_fill_func
5050
from pandas.core.sorting import nargminmax, nargsort
5151

52-
_extension_array_shared_docs: Dict[str, str] = dict()
52+
_extension_array_shared_docs: Dict[str, str] = {}
5353

5454
ExtensionArrayT = TypeVar("ExtensionArrayT", bound="ExtensionArray")
5555

@@ -952,7 +952,7 @@ def factorize(self, na_sentinel: int = -1) -> Tuple[np.ndarray, ExtensionArray]:
952952
@Substitution(klass="ExtensionArray")
953953
@Appender(_extension_array_shared_docs["repeat"])
954954
def repeat(self, repeats, axis=None):
955-
nv.validate_repeat(tuple(), dict(axis=axis))
955+
nv.validate_repeat(tuple(), {"axis": axis})
956956
ind = np.arange(len(self)).repeat(repeats)
957957
return self.take(ind)
958958

pandas/core/computation/pytables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(
3535
queryables: Optional[Dict[str, Any]] = None,
3636
):
3737
super().__init__(level + 1, global_dict=global_dict, local_dict=local_dict)
38-
self.queryables = queryables or dict()
38+
self.queryables = queryables or {}
3939

4040

4141
class Term(ops.Term):

pandas/core/indexes/base.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@
106106

107107
_unsortable_types = frozenset(("mixed", "mixed-integer"))
108108

109-
_index_doc_kwargs = dict(
110-
klass="Index",
111-
inplace="",
112-
target_klass="Index",
113-
raises_section="",
114-
unique="Index",
115-
duplicated="np.ndarray",
116-
)
117-
_index_shared_docs = dict()
109+
_index_doc_kwargs = {
110+
"klass": "Index",
111+
"inplace": "",
112+
"target_klass": "Index",
113+
"raises_section": "",
114+
"unique": "Index",
115+
"duplicated": "np.ndarray",
116+
}
117+
_index_shared_docs = {}
118118
str_t = str
119119

120120

@@ -817,7 +817,7 @@ def _maybe_disallow_fill(self, allow_fill: bool, fill_value, indices) -> bool:
817817
@Appender(_index_shared_docs["repeat"] % _index_doc_kwargs)
818818
def repeat(self, repeats, axis=None):
819819
repeats = ensure_platform_int(repeats)
820-
nv.validate_repeat(tuple(), dict(axis=axis))
820+
nv.validate_repeat(tuple(), {"axis": axis})
821821
return self._shallow_copy(self._values.repeat(repeats))
822822

823823
# --------------------------------------------------------------------
@@ -2155,7 +2155,7 @@ def is_all_dates(self):
21552155
# Pickle Methods
21562156

21572157
def __reduce__(self):
2158-
d = dict(data=self._data)
2158+
d = {"data": self._data}
21592159
d.update(self._get_attributes_dict())
21602160
return _new_Index, (type(self), d), None
21612161

pandas/core/ops/methods.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def add_flex_arithmetic_methods(cls):
6262
flex_arith_method, flex_comp_method = _get_method_wrappers(cls)
6363
new_methods = _create_methods(cls, flex_arith_method, flex_comp_method)
6464
new_methods.update(
65-
dict(
66-
multiply=new_methods["mul"],
67-
subtract=new_methods["sub"],
68-
divide=new_methods["div"],
69-
)
65+
{
66+
"multiply": new_methods["mul"],
67+
"subtract": new_methods["sub"],
68+
"divide": new_methods["div"],
69+
}
7070
)
7171
# opt out of bool flex methods for now
7272
assert not any(kname in new_methods for kname in ("ror_", "rxor", "rand_"))
@@ -84,22 +84,22 @@ def _create_methods(cls, arith_method, comp_method):
8484
new_methods = {}
8585

8686
new_methods.update(
87-
dict(
88-
add=arith_method(operator.add),
89-
radd=arith_method(radd),
90-
sub=arith_method(operator.sub),
91-
mul=arith_method(operator.mul),
92-
truediv=arith_method(operator.truediv),
93-
floordiv=arith_method(operator.floordiv),
94-
mod=arith_method(operator.mod),
95-
pow=arith_method(operator.pow),
96-
rmul=arith_method(rmul),
97-
rsub=arith_method(rsub),
98-
rtruediv=arith_method(rtruediv),
99-
rfloordiv=arith_method(rfloordiv),
100-
rpow=arith_method(rpow),
101-
rmod=arith_method(rmod),
102-
)
87+
{
88+
"add": arith_method(operator.add),
89+
"radd": arith_method(radd),
90+
"sub": arith_method(operator.sub),
91+
"mul": arith_method(operator.mul),
92+
"truediv": arith_method(operator.truediv),
93+
"floordiv": arith_method(operator.floordiv),
94+
"mod": arith_method(operator.mod),
95+
"pow": arith_method(operator.pow),
96+
"rmul": arith_method(rmul),
97+
"rsub": arith_method(rsub),
98+
"rtruediv": arith_method(rtruediv),
99+
"rfloordiv": arith_method(rfloordiv),
100+
"rpow": arith_method(rpow),
101+
"rmod": arith_method(rmod),
102+
}
103103
)
104104
new_methods["div"] = new_methods["truediv"]
105105
new_methods["rdiv"] = new_methods["rtruediv"]
@@ -109,14 +109,14 @@ def _create_methods(cls, arith_method, comp_method):
109109
new_methods["rdivmod"] = arith_method(rdivmod)
110110

111111
new_methods.update(
112-
dict(
113-
eq=comp_method(operator.eq),
114-
ne=comp_method(operator.ne),
115-
lt=comp_method(operator.lt),
116-
gt=comp_method(operator.gt),
117-
le=comp_method(operator.le),
118-
ge=comp_method(operator.ge),
119-
)
112+
{
113+
"eq": comp_method(operator.eq),
114+
"ne": comp_method(operator.ne),
115+
"lt": comp_method(operator.lt),
116+
"gt": comp_method(operator.gt),
117+
"le": comp_method(operator.le),
118+
"ge": comp_method(operator.ge),
119+
}
120120
)
121121

122122
new_methods = {k.strip("_"): v for k, v in new_methods.items()}

pandas/io/pytables.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ def convert(self, values: np.ndarray, nan_rep, encoding: str, errors: str):
20372037
val_kind = _ensure_decoded(self.kind)
20382038
values = _maybe_convert(values, val_kind, encoding, errors)
20392039

2040-
kwargs = dict()
2040+
kwargs = {}
20412041
kwargs["name"] = _ensure_decoded(self.index_name)
20422042

20432043
if self.freq is not None:
@@ -3237,7 +3237,7 @@ def __init__(
32373237
self.non_index_axes = non_index_axes or []
32383238
self.values_axes = values_axes or []
32393239
self.data_columns = data_columns or []
3240-
self.info = info or dict()
3240+
self.info = info or {}
32413241
self.nan_rep = nan_rep
32423242

32433243
@property
@@ -3446,7 +3446,7 @@ def get_attrs(self):
34463446
""" retrieve our attributes """
34473447
self.non_index_axes = getattr(self.attrs, "non_index_axes", None) or []
34483448
self.data_columns = getattr(self.attrs, "data_columns", None) or []
3449-
self.info = getattr(self.attrs, "info", None) or dict()
3449+
self.info = getattr(self.attrs, "info", None) or {}
34503450
self.nan_rep = getattr(self.attrs, "nan_rep", None)
34513451
self.encoding = _ensure_encoding(getattr(self.attrs, "encoding", None))
34523452
self.errors = _ensure_decoded(getattr(self.attrs, "errors", "strict"))
@@ -3596,7 +3596,7 @@ def create_index(self, columns=None, optlevel=None, kind: Optional[str] = None):
35963596
if not isinstance(columns, (tuple, list)):
35973597
columns = [columns]
35983598

3599-
kw = dict()
3599+
kw = {}
36003600
if optlevel is not None:
36013601
kw["optlevel"] = optlevel
36023602
if kind is not None:
@@ -3689,7 +3689,7 @@ def validate_data_columns(self, data_columns, min_itemsize, non_index_axes):
36893689
return []
36903690

36913691
axis, axis_labels = non_index_axes[0]
3692-
info = self.info.get(axis, dict())
3692+
info = self.info.get(axis, {})
36933693
if info.get("type") == "MultiIndex" and data_columns:
36943694
raise ValueError(
36953695
f"cannot use a multi-index on axis [{axis}] with "
@@ -4071,7 +4071,7 @@ def create_description(
40714071
if expectedrows is None:
40724072
expectedrows = max(self.nrows_expected, 10000)
40734073

4074-
d = dict(name="table", expectedrows=expectedrows)
4074+
d = {"name": "table", "expectedrows": expectedrows}
40754075

40764076
# description from the axes & values
40774077
d["description"] = {a.cname: a.typ for a in self.axes}
@@ -4458,9 +4458,9 @@ def read(
44584458
result = self._read_axes(where=where, start=start, stop=stop)
44594459

44604460
info = (
4461-
self.info.get(self.non_index_axes[0][0], dict())
4461+
self.info.get(self.non_index_axes[0][0], {})
44624462
if len(self.non_index_axes)
4463-
else dict()
4463+
else {}
44644464
)
44654465

44664466
inds = [i for i, ax in enumerate(self.axes) if ax is self.index_axes[0]]

0 commit comments

Comments
 (0)