Skip to content

Commit b58880c

Browse files
authored
C408 rewrite dict call to dict literals (#38263)
1 parent 5a13697 commit b58880c

File tree

2 files changed

+92
-86
lines changed

2 files changed

+92
-86
lines changed

pandas/core/arrays/interval.py

+41-39
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757

5858
_interval_shared_docs = {}
5959

60-
_shared_docs_kwargs = dict(
61-
klass="IntervalArray", qualname="arrays.IntervalArray", name=""
62-
)
60+
_shared_docs_kwargs = {
61+
"klass": "IntervalArray",
62+
"qualname": "arrays.IntervalArray",
63+
"name": "",
64+
}
6365

6466

6567
_interval_shared_docs[
@@ -127,14 +129,14 @@
127129

128130
@Appender(
129131
_interval_shared_docs["class"]
130-
% dict(
131-
klass="IntervalArray",
132-
summary="Pandas array for interval data that are closed on the same side.",
133-
versionadded="0.24.0",
134-
name="",
135-
extra_attributes="",
136-
extra_methods="",
137-
examples=textwrap.dedent(
132+
% {
133+
"klass": "IntervalArray",
134+
"summary": "Pandas array for interval data that are closed on the same side.",
135+
"versionadded": "0.24.0",
136+
"name": "",
137+
"extra_attributes": "",
138+
"extra_methods": "",
139+
"examples": textwrap.dedent(
138140
"""\
139141
Examples
140142
--------
@@ -151,7 +153,7 @@
151153
:meth:`IntervalArray.from_breaks`, and :meth:`IntervalArray.from_tuples`.
152154
"""
153155
),
154-
)
156+
}
155157
)
156158
class IntervalArray(IntervalMixin, ExtensionArray):
157159
ndim = 1
@@ -319,9 +321,9 @@ def _from_factorized(cls, values, original):
319321
@classmethod
320322
@Appender(
321323
_interval_shared_docs["from_breaks"]
322-
% dict(
323-
klass="IntervalArray",
324-
examples=textwrap.dedent(
324+
% {
325+
"klass": "IntervalArray",
326+
"examples": textwrap.dedent(
325327
"""\
326328
Examples
327329
--------
@@ -331,7 +333,7 @@ def _from_factorized(cls, values, original):
331333
Length: 3, closed: right, dtype: interval[int64]
332334
"""
333335
),
334-
)
336+
}
335337
)
336338
def from_breaks(cls, breaks, closed="right", copy=False, dtype=None):
337339
breaks = maybe_convert_platform_interval(breaks)
@@ -390,17 +392,17 @@ def from_breaks(cls, breaks, closed="right", copy=False, dtype=None):
390392
@classmethod
391393
@Appender(
392394
_interval_shared_docs["from_arrays"]
393-
% dict(
394-
klass="IntervalArray",
395-
examples=textwrap.dedent(
395+
% {
396+
"klass": "IntervalArray",
397+
"examples": textwrap.dedent(
396398
"""\
397399
>>> pd.arrays.IntervalArray.from_arrays([0, 1, 2], [1, 2, 3])
398400
<IntervalArray>
399401
[(0, 1], (1, 2], (2, 3]]
400402
Length: 3, closed: right, dtype: interval[int64]
401403
"""
402404
),
403-
)
405+
}
404406
)
405407
def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
406408
left = maybe_convert_platform_interval(left)
@@ -445,9 +447,9 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
445447
@classmethod
446448
@Appender(
447449
_interval_shared_docs["from_tuples"]
448-
% dict(
449-
klass="IntervalArray",
450-
examples=textwrap.dedent(
450+
% {
451+
"klass": "IntervalArray",
452+
"examples": textwrap.dedent(
451453
"""\
452454
Examples
453455
--------
@@ -457,7 +459,7 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
457459
Length: 2, closed: right, dtype: interval[int64]
458460
"""
459461
),
460-
)
462+
}
461463
)
462464
def from_tuples(cls, data, closed="right", copy=False, dtype=None):
463465
if len(data):
@@ -904,7 +906,7 @@ def take(self, indices, *, allow_fill=False, fill_value=None, axis=None, **kwarg
904906
When `indices` contains negative values other than ``-1``
905907
and `allow_fill` is True.
906908
"""
907-
nv.validate_take(tuple(), kwargs)
909+
nv.validate_take((), kwargs)
908910

909911
fill_left = fill_right = fill_value
910912
if allow_fill:
@@ -1144,9 +1146,9 @@ def mid(self):
11441146

11451147
@Appender(
11461148
_interval_shared_docs["overlaps"]
1147-
% dict(
1148-
klass="IntervalArray",
1149-
examples=textwrap.dedent(
1149+
% {
1150+
"klass": "IntervalArray",
1151+
"examples": textwrap.dedent(
11501152
"""\
11511153
>>> data = [(0, 1), (1, 3), (2, 4)]
11521154
>>> intervals = pd.arrays.IntervalArray.from_tuples(data)
@@ -1156,7 +1158,7 @@ def mid(self):
11561158
Length: 3, closed: right, dtype: interval[int64]
11571159
"""
11581160
),
1159-
)
1161+
}
11601162
)
11611163
def overlaps(self, other):
11621164
if isinstance(other, (IntervalArray, ABCIntervalIndex)):
@@ -1207,9 +1209,9 @@ def closed(self):
12071209

12081210
@Appender(
12091211
_interval_shared_docs["set_closed"]
1210-
% dict(
1211-
klass="IntervalArray",
1212-
examples=textwrap.dedent(
1212+
% {
1213+
"klass": "IntervalArray",
1214+
"examples": textwrap.dedent(
12131215
"""\
12141216
Examples
12151217
--------
@@ -1224,7 +1226,7 @@ def closed(self):
12241226
Length: 3, closed: both, dtype: interval[int64]
12251227
"""
12261228
),
1227-
)
1229+
}
12281230
)
12291231
def set_closed(self, closed):
12301232
if closed not in VALID_CLOSED:
@@ -1360,7 +1362,7 @@ def __arrow_array__(self, type=None):
13601362
"""
13611363

13621364
@Appender(
1363-
_interval_shared_docs["to_tuples"] % dict(return_type="ndarray", examples="")
1365+
_interval_shared_docs["to_tuples"] % {"return_type": "ndarray", "examples": ""}
13641366
)
13651367
def to_tuples(self, na_tuple=True):
13661368
tuples = com.asarray_tuplesafe(zip(self._left, self._right))
@@ -1373,7 +1375,7 @@ def to_tuples(self, na_tuple=True):
13731375

13741376
@Appender(_extension_array_shared_docs["repeat"] % _shared_docs_kwargs)
13751377
def repeat(self, repeats, axis=None):
1376-
nv.validate_repeat(tuple(), dict(axis=axis))
1378+
nv.validate_repeat((), {"axis": axis})
13771379
left_repeat = self.left.repeat(repeats)
13781380
right_repeat = self.right.repeat(repeats)
13791381
return self._shallow_copy(left=left_repeat, right=right_repeat)
@@ -1412,9 +1414,9 @@ def repeat(self, repeats, axis=None):
14121414

14131415
@Appender(
14141416
_interval_shared_docs["contains"]
1415-
% dict(
1416-
klass="IntervalArray",
1417-
examples=textwrap.dedent(
1417+
% {
1418+
"klass": "IntervalArray",
1419+
"examples": textwrap.dedent(
14181420
"""\
14191421
>>> intervals = pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 3), (2, 4)])
14201422
>>> intervals
@@ -1423,7 +1425,7 @@ def repeat(self, repeats, axis=None):
14231425
Length: 3, closed: right, dtype: interval[int64]
14241426
"""
14251427
),
1426-
)
1428+
}
14271429
)
14281430
def contains(self, other):
14291431
if isinstance(other, Interval):

0 commit comments

Comments
 (0)