Skip to content

Commit c04bba4

Browse files
authored
CI: Upgrade mypy to 0.990 (#49626)
1 parent 18aca9c commit c04bba4

File tree

13 files changed

+30
-41
lines changed

13 files changed

+30
-41
lines changed

doc/source/whatsnew/v2.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ If installed, we now require:
298298
+-----------------+-----------------+----------+---------+
299299
| Package | Minimum Version | Required | Changed |
300300
+=================+=================+==========+=========+
301-
| mypy (dev) | 0.981 | | X |
301+
| mypy (dev) | 0.990 | | X |
302302
+-----------------+-----------------+----------+---------+
303303
| python-dateutil | 2.8.2 | X | X |
304304
+-----------------+-----------------+----------+---------+

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ dependencies:
8888
- flake8=5.0.4
8989
- flake8-bugbear=22.7.1 # used by flake8, find likely bugs
9090
- isort>=5.2.1 # check that imports are in the right order
91-
- mypy=0.981
91+
- mypy=0.990
9292
- pre-commit>=2.15.0
9393
- pycodestyle # used by flake8
9494
- pyupgrade

pandas/_libs/tslibs/offsets.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ class CustomBusinessHour(BusinessHour):
253253

254254
class CustomBusinessMonthEnd(_CustomBusinessMonth): ...
255255
class CustomBusinessMonthBegin(_CustomBusinessMonth): ...
256-
class DateOffset(RelativeDeltaOffset): ...
256+
class OffsetMeta(type): ...
257+
class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta): ...
257258

258259
BDay = BusinessDay
259260
BMonthEnd = BusinessMonthEnd

pandas/core/apply.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def agg_dict_like(self) -> DataFrame | Series:
414414

415415
axis: AxisInt = 0 if isinstance(obj, ABCSeries) else 1
416416
result = concat(
417-
{k: results[k] for k in keys_to_use}, # type: ignore[misc]
417+
{k: results[k] for k in keys_to_use},
418418
axis=axis,
419419
keys=keys_to_use,
420420
)

pandas/core/arrays/base.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1646,10 +1646,12 @@ def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):
16461646

16471647

16481648
class ExtensionArraySupportsAnyAll(ExtensionArray):
1649-
def any(self, *, skipna: bool = True) -> bool:
1649+
def any(self, *, skipna: bool = True) -> bool: # type: ignore[empty-body]
1650+
# error: Missing return statement
16501651
pass
16511652

1652-
def all(self, *, skipna: bool = True) -> bool:
1653+
def all(self, *, skipna: bool = True) -> bool: # type: ignore[empty-body]
1654+
# error: Missing return statement
16531655
pass
16541656

16551657

pandas/core/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1107,9 +1107,9 @@ def _memory_usage(self, deep: bool = False) -> int:
11071107
are not components of the array if deep=False or if used on PyPy
11081108
"""
11091109
if hasattr(self.array, "memory_usage"):
1110-
# https://github.com/python/mypy/issues/1424
1111-
# error: "ExtensionArray" has no attribute "memory_usage"
1112-
return self.array.memory_usage(deep=deep) # type: ignore[attr-defined]
1110+
return self.array.memory_usage( # pyright: ignore[reportGeneralTypeIssues]
1111+
deep=deep,
1112+
)
11131113

11141114
v = self.array.nbytes
11151115
if deep and is_object_dtype(self) and not PYPY:

pandas/core/frame.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -5444,9 +5444,8 @@ def fillna(
54445444
) -> DataFrame | None:
54455445
...
54465446

5447-
# error: Signature of "fillna" incompatible with supertype "NDFrame"
54485447
@doc(NDFrame.fillna, **_shared_doc_kwargs)
5449-
def fillna( # type: ignore[override]
5448+
def fillna(
54505449
self,
54515450
value: Hashable | Mapping | Series | DataFrame = None,
54525451
*,
@@ -5535,9 +5534,8 @@ def replace(
55355534
) -> None:
55365535
...
55375536

5538-
# error: Signature of "replace" incompatible with supertype "NDFrame"
55395537
@doc(NDFrame.replace, **_shared_doc_kwargs)
5540-
def replace( # type: ignore[override]
5538+
def replace(
55415539
self,
55425540
to_replace=None,
55435541
value=lib.no_default,
@@ -6682,10 +6680,9 @@ def sort_values(
66826680
...
66836681

66846682
# TODO: Just move the sort_values doc here.
6685-
# error: Signature of "sort_values" incompatible with supertype "NDFrame"
66866683
@Substitution(**_shared_doc_kwargs)
66876684
@Appender(NDFrame.sort_values.__doc__)
6688-
def sort_values( # type: ignore[override]
6685+
def sort_values(
66896686
self,
66906687
by: IndexLabel,
66916688
*,
@@ -9205,8 +9202,9 @@ def any(
92059202
) -> DataFrame | Series:
92069203
...
92079204

9205+
# error: Missing return statement
92089206
@doc(NDFrame.any, **_shared_doc_kwargs)
9209-
def any(
9207+
def any( # type: ignore[empty-body]
92109208
self,
92119209
axis: Axis = 0,
92129210
bool_only: bool | None = None,

pandas/core/interchange/column.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ def __init__(self, column: pd.Series, allow_copy: bool = True) -> None:
8181
self._col = column
8282
self._allow_copy = allow_copy
8383

84-
def size(self) -> int:
84+
def size(self) -> int: # type: ignore[override]
8585
"""
8686
Size of the column, in elements.
8787
"""
88+
# error: Signature of "size" incompatible with supertype "Column" [override]
8889
return self._col.size
8990

9091
@property

pandas/core/series.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -1653,14 +1653,9 @@ def to_string(
16531653
return result
16541654
else:
16551655
if hasattr(buf, "write"):
1656-
# error: Item "str" of "Union[str, PathLike[str], WriteBuffer
1657-
# [str]]" has no attribute "write"
1658-
buf.write(result) # type: ignore[union-attr]
1656+
buf.write(result)
16591657
else:
1660-
# error: Argument 1 to "open" has incompatible type "Union[str,
1661-
# PathLike[str], WriteBuffer[str]]"; expected "Union[Union[str,
1662-
# bytes, PathLike[str], PathLike[bytes]], int]"
1663-
with open(buf, "w") as f: # type: ignore[arg-type]
1658+
with open(buf, "w") as f:
16641659
f.write(result)
16651660
return None
16661661

@@ -4406,8 +4401,9 @@ def any(
44064401
) -> Series | bool:
44074402
...
44084403

4404+
# error: Missing return statement
44094405
@doc(NDFrame.any, **_shared_doc_kwargs)
4410-
def any(
4406+
def any( # type: ignore[empty-body]
44114407
self,
44124408
axis: Axis = 0,
44134409
bool_only: bool | None = None,
@@ -5015,9 +5011,8 @@ def fillna(
50155011
) -> Series | None:
50165012
...
50175013

5018-
# error: Signature of "fillna" incompatible with supertype "NDFrame"
50195014
@doc(NDFrame.fillna, **_shared_doc_kwargs)
5020-
def fillna( # type: ignore[override]
5015+
def fillna(
50215016
self,
50225017
value: Hashable | Mapping | Series | DataFrame = None,
50235018
*,
@@ -5090,14 +5085,13 @@ def replace(
50905085
) -> None:
50915086
...
50925087

5093-
# error: Signature of "replace" incompatible with supertype "NDFrame"
50945088
@doc(
50955089
NDFrame.replace,
50965090
klass=_shared_doc_kwargs["klass"],
50975091
inplace=_shared_doc_kwargs["inplace"],
50985092
replace_iloc=_shared_doc_kwargs["replace_iloc"],
50995093
)
5100-
def replace( # type: ignore[override]
5094+
def replace(
51015095
self,
51025096
to_replace=None,
51035097
value=lib.no_default,

pandas/io/common.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,7 @@ def __getattr__(self, name: str):
10531053

10541054
def readable(self) -> bool:
10551055
if hasattr(self.buffer, "readable"):
1056-
# error: "BaseBuffer" has no attribute "readable"
1057-
return self.buffer.readable() # type: ignore[attr-defined]
1056+
return self.buffer.readable()
10581057
return True
10591058

10601059
def seekable(self) -> bool:
@@ -1064,8 +1063,7 @@ def seekable(self) -> bool:
10641063

10651064
def writable(self) -> bool:
10661065
if hasattr(self.buffer, "writable"):
1067-
# error: "BaseBuffer" has no attribute "writable"
1068-
return self.buffer.writable() # type: ignore[attr-defined]
1066+
return self.buffer.writable()
10691067
return True
10701068

10711069

pandas/plotting/_core.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1835,8 +1835,7 @@ def _load_backend(backend: str) -> types.ModuleType:
18351835
# entry_points lost dict API ~ PY 3.10
18361836
# https://github.com/python/importlib_metadata/issues/298
18371837
if hasattr(eps, "select"):
1838-
# error: "Dict[str, Tuple[EntryPoint, ...]]" has no attribute "select"
1839-
entry = eps.select(group=key) # type: ignore[attr-defined]
1838+
entry = eps.select(group=key) # pyright: ignore[reportGeneralTypeIssues]
18401839
else:
18411840
entry = eps.get(key, ())
18421841
for entry_point in entry:

pandas/util/_decorators.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,8 @@ def decorator(decorated: F) -> F:
397397
if docstring is None:
398398
continue
399399
if hasattr(docstring, "_docstring_components"):
400-
# error: Item "str" of "Union[str, Callable[..., Any]]" has no attribute
401-
# "_docstring_components"
402-
# error: Item "function" of "Union[str, Callable[..., Any]]" has no
403-
# attribute "_docstring_components"
404400
docstring_components.extend(
405-
docstring._docstring_components # type: ignore[union-attr]
401+
docstring._docstring_components # pyright: ignore[reportGeneralTypeIssues] # noqa: E501
406402
)
407403
elif isinstance(docstring, str) or docstring.__doc__:
408404
docstring_components.append(docstring)

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ cpplint
6767
flake8==5.0.4
6868
flake8-bugbear==22.7.1
6969
isort>=5.2.1
70-
mypy==0.981
70+
mypy==0.990
7171
pre-commit>=2.15.0
7272
pycodestyle
7373
pyupgrade

0 commit comments

Comments
 (0)