Skip to content

Commit 54ba22a

Browse files
jbrockmendelproost
authored andcommitted
CLN: fix mypy warnings/errors (pandas-dev#29327)
1 parent 2c7c081 commit 54ba22a

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

pandas/core/groupby/ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def _get_axes(group):
790790
return group.axes
791791

792792

793-
def _is_indexed_like(obj, axes):
793+
def _is_indexed_like(obj, axes) -> bool:
794794
if isinstance(obj, Series):
795795
if len(axes) > 1:
796796
return False

pandas/core/indexes/frozen.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
- .levels & .codes (FrozenNDArray)
88
99
"""
10-
1110
import warnings
1211

1312
import numpy as np
@@ -31,7 +30,7 @@ class FrozenList(PandasObject, list):
3130
# Side note: This has to be of type list. Otherwise,
3231
# it messes up PyTables type checks.
3332

34-
def union(self, other):
33+
def union(self, other) -> "FrozenList":
3534
"""
3635
Returns a FrozenList with other concatenated to the end of self.
3736
@@ -49,7 +48,7 @@ def union(self, other):
4948
other = list(other)
5049
return type(self)(super().__add__(other))
5150

52-
def difference(self, other):
51+
def difference(self, other) -> "FrozenList":
5352
"""
5453
Returns a FrozenList with elements from other removed from self.
5554
@@ -101,7 +100,9 @@ def __hash__(self):
101100
def _disabled(self, *args, **kwargs):
102101
"""This method will not function because object is immutable."""
103102
raise TypeError(
104-
"'%s' does not support mutable operations." % self.__class__.__name__
103+
"'{cls}' does not support mutable operations.".format(
104+
cls=self.__class__.__name__
105+
)
105106
)
106107

107108
def __str__(self):
@@ -132,7 +133,9 @@ def __new__(cls, data, dtype=None, copy=False):
132133

133134
def _disabled(self, *args, **kwargs):
134135
"""This method will not function because object is immutable."""
135-
raise TypeError("'%s' does not support mutable operations." % self.__class__)
136+
raise TypeError(
137+
"'{cls}' does not support mutable operations.".format(cls=self.__class__)
138+
)
136139

137140
__setitem__ = __setslice__ = __delitem__ = __delslice__ = _disabled
138141
put = itemset = fill = _disabled

pandas/io/formats/css.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ class CSSWarning(UserWarning):
1111
pass
1212

1313

14+
def _side_expander(prop_fmt: str):
15+
def expand(self, prop, value):
16+
tokens = value.split()
17+
try:
18+
mapping = self.SIDE_SHORTHANDS[len(tokens)]
19+
except KeyError:
20+
warnings.warn(
21+
'Could not expand "{prop}: {val}"'.format(prop=prop, val=value),
22+
CSSWarning,
23+
)
24+
return
25+
for key, idx in zip(self.SIDES, mapping):
26+
yield prop_fmt.format(key), tokens[idx]
27+
28+
return expand
29+
30+
1431
class CSSResolver:
1532
"""A callable for parsing and resolving CSS to atomic properties
1633
@@ -213,22 +230,6 @@ def atomize(self, declarations):
213230
}
214231
SIDES = ("top", "right", "bottom", "left")
215232

216-
def _side_expander(prop_fmt):
217-
def expand(self, prop, value):
218-
tokens = value.split()
219-
try:
220-
mapping = self.SIDE_SHORTHANDS[len(tokens)]
221-
except KeyError:
222-
warnings.warn(
223-
'Could not expand "{prop}: {val}"'.format(prop=prop, val=value),
224-
CSSWarning,
225-
)
226-
return
227-
for key, idx in zip(self.SIDES, mapping):
228-
yield prop_fmt.format(key), tokens[idx]
229-
230-
return expand
231-
232233
expand_border_color = _side_expander("border-{:s}-color")
233234
expand_border_style = _side_expander("border-{:s}-style")
234235
expand_border_width = _side_expander("border-{:s}-width")

pandas/tests/io/msgpack/test_extension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def default(obj):
4848
typecode = 123 # application specific typecode
4949
data = tobytes(obj)
5050
return ExtType(typecode, data)
51-
raise TypeError("Unknown type object {obj!r}".format(obj))
51+
raise TypeError("Unknown type object {obj!r}".format(obj=obj))
5252

5353
def ext_hook(code, data):
5454
print("ext_hook called", code, data)

0 commit comments

Comments
 (0)