Skip to content

C408 rewrite dict call to dict literals #38263

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
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
80 changes: 41 additions & 39 deletions pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@

_interval_shared_docs = {}

_shared_docs_kwargs = dict(
klass="IntervalArray", qualname="arrays.IntervalArray", name=""
)
_shared_docs_kwargs = {
"klass": "IntervalArray",
"qualname": "arrays.IntervalArray",
"name": "",
}


_interval_shared_docs[
Expand Down Expand Up @@ -127,14 +129,14 @@

@Appender(
_interval_shared_docs["class"]
% dict(
klass="IntervalArray",
summary="Pandas array for interval data that are closed on the same side.",
versionadded="0.24.0",
name="",
extra_attributes="",
extra_methods="",
examples=textwrap.dedent(
% {
"klass": "IntervalArray",
"summary": "Pandas array for interval data that are closed on the same side.",
"versionadded": "0.24.0",
"name": "",
"extra_attributes": "",
"extra_methods": "",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -151,7 +153,7 @@
:meth:`IntervalArray.from_breaks`, and :meth:`IntervalArray.from_tuples`.
"""
),
)
}
)
class IntervalArray(IntervalMixin, ExtensionArray):
ndim = 1
Expand Down Expand Up @@ -319,9 +321,9 @@ def _from_factorized(cls, values, original):
@classmethod
@Appender(
_interval_shared_docs["from_breaks"]
% dict(
klass="IntervalArray",
examples=textwrap.dedent(
% {
"klass": "IntervalArray",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -331,7 +333,7 @@ def _from_factorized(cls, values, original):
Length: 3, closed: right, dtype: interval[int64]
"""
),
)
}
)
def from_breaks(cls, breaks, closed="right", copy=False, dtype=None):
breaks = maybe_convert_platform_interval(breaks)
Expand Down Expand Up @@ -390,17 +392,17 @@ def from_breaks(cls, breaks, closed="right", copy=False, dtype=None):
@classmethod
@Appender(
_interval_shared_docs["from_arrays"]
% dict(
klass="IntervalArray",
examples=textwrap.dedent(
% {
"klass": "IntervalArray",
"examples": textwrap.dedent(
"""\
>>> pd.arrays.IntervalArray.from_arrays([0, 1, 2], [1, 2, 3])
<IntervalArray>
[(0, 1], (1, 2], (2, 3]]
Length: 3, closed: right, dtype: interval[int64]
"""
),
)
}
)
def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
left = maybe_convert_platform_interval(left)
Expand Down Expand Up @@ -445,9 +447,9 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
@classmethod
@Appender(
_interval_shared_docs["from_tuples"]
% dict(
klass="IntervalArray",
examples=textwrap.dedent(
% {
"klass": "IntervalArray",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -457,7 +459,7 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
Length: 2, closed: right, dtype: interval[int64]
"""
),
)
}
)
def from_tuples(cls, data, closed="right", copy=False, dtype=None):
if len(data):
Expand Down Expand Up @@ -904,7 +906,7 @@ def take(self, indices, *, allow_fill=False, fill_value=None, axis=None, **kwarg
When `indices` contains negative values other than ``-1``
and `allow_fill` is True.
"""
nv.validate_take(tuple(), kwargs)
nv.validate_take((), kwargs)

fill_left = fill_right = fill_value
if allow_fill:
Expand Down Expand Up @@ -1144,9 +1146,9 @@ def mid(self):

@Appender(
_interval_shared_docs["overlaps"]
% dict(
klass="IntervalArray",
examples=textwrap.dedent(
% {
"klass": "IntervalArray",
"examples": textwrap.dedent(
"""\
>>> data = [(0, 1), (1, 3), (2, 4)]
>>> intervals = pd.arrays.IntervalArray.from_tuples(data)
Expand All @@ -1156,7 +1158,7 @@ def mid(self):
Length: 3, closed: right, dtype: interval[int64]
"""
),
)
}
)
def overlaps(self, other):
if isinstance(other, (IntervalArray, ABCIntervalIndex)):
Expand Down Expand Up @@ -1207,9 +1209,9 @@ def closed(self):

@Appender(
_interval_shared_docs["set_closed"]
% dict(
klass="IntervalArray",
examples=textwrap.dedent(
% {
"klass": "IntervalArray",
"examples": textwrap.dedent(
"""\
Examples
--------
Expand All @@ -1224,7 +1226,7 @@ def closed(self):
Length: 3, closed: both, dtype: interval[int64]
"""
),
)
}
)
def set_closed(self, closed):
if closed not in VALID_CLOSED:
Expand Down Expand Up @@ -1360,7 +1362,7 @@ def __arrow_array__(self, type=None):
"""

@Appender(
_interval_shared_docs["to_tuples"] % dict(return_type="ndarray", examples="")
_interval_shared_docs["to_tuples"] % {"return_type": "ndarray", "examples": ""}
)
def to_tuples(self, na_tuple=True):
tuples = com.asarray_tuplesafe(zip(self._left, self._right))
Expand All @@ -1373,7 +1375,7 @@ def to_tuples(self, na_tuple=True):

@Appender(_extension_array_shared_docs["repeat"] % _shared_docs_kwargs)
def repeat(self, repeats, axis=None):
nv.validate_repeat(tuple(), dict(axis=axis))
nv.validate_repeat((), {"axis": axis})
left_repeat = self.left.repeat(repeats)
right_repeat = self.right.repeat(repeats)
return self._shallow_copy(left=left_repeat, right=right_repeat)
Expand Down Expand Up @@ -1412,9 +1414,9 @@ def repeat(self, repeats, axis=None):

@Appender(
_interval_shared_docs["contains"]
% dict(
klass="IntervalArray",
examples=textwrap.dedent(
% {
"klass": "IntervalArray",
"examples": textwrap.dedent(
"""\
>>> intervals = pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 3), (2, 4)])
>>> intervals
Expand All @@ -1423,7 +1425,7 @@ def repeat(self, repeats, axis=None):
Length: 3, closed: right, dtype: interval[int64]
"""
),
)
}
)
def contains(self, other):
if isinstance(other, Interval):
Expand Down
Loading