Skip to content

Commit 9222cb0

Browse files
authored
TYP/CI: bump mypy&pyright (#46905)
1 parent 0e9a110 commit 9222cb0

File tree

9 files changed

+19
-26
lines changed

9 files changed

+19
-26
lines changed

.github/workflows/code-checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474

7575
- name: Install pyright
7676
# note: keep version in sync with .pre-commit-config.yaml
77-
run: npm install -g [email protected].245
77+
run: npm install -g [email protected].247
7878

7979
- name: Build Pandas
8080
id: build

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ repos:
8989
types: [python]
9090
stages: [manual]
9191
# note: keep version in sync with .github/workflows/code-checks.yml
92-
additional_dependencies: ['[email protected].245']
92+
additional_dependencies: ['[email protected].247']
9393
- repo: local
9494
hooks:
9595
- id: flake8-rst

doc/source/whatsnew/v1.5.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ If installed, we now require:
360360
+-----------------+-----------------+----------+---------+
361361
| Package | Minimum Version | Required | Changed |
362362
+=================+=================+==========+=========+
363-
| mypy (dev) | 0.941 | | X |
363+
| mypy (dev) | 0.950 | | X |
364364
+-----------------+-----------------+----------+---------+
365365

366366

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies:
2424
- flake8-bugbear=21.3.2 # used by flake8, find likely bugs
2525
- flake8-comprehensions=3.7.0 # used by flake8, linting of unnecessary comprehensions
2626
- isort>=5.2.1 # check that imports are in the right order
27-
- mypy=0.941
27+
- mypy=0.950
2828
- pre-commit>=2.9.2
2929
- pycodestyle # used by flake8
3030
- pyupgrade

pandas/_config/localization.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def set_locale(
4545
locale.setlocale(lc_var, new_locale)
4646
normalized_locale = locale.getlocale()
4747
if all(x is not None for x in normalized_locale):
48-
yield ".".join(normalized_locale)
48+
# error: Argument 1 to "join" of "str" has incompatible type
49+
# "Tuple[Optional[str], Optional[str]]"; expected "Iterable[str]"
50+
yield ".".join(normalized_locale) # type: ignore[arg-type]
4951
else:
5052
yield new_locale
5153
finally:

pandas/_libs/tslibs/timestamps.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Timestamp(datetime):
113113
def time(self) -> _time: ...
114114
def timetz(self) -> _time: ...
115115
def replace(
116-
self,
116+
self: _DatetimeT,
117117
year: int = ...,
118118
month: int = ...,
119119
day: int = ...,
@@ -123,7 +123,7 @@ class Timestamp(datetime):
123123
microsecond: int = ...,
124124
tzinfo: _tzinfo | None = ...,
125125
fold: int = ...,
126-
) -> datetime: ...
126+
) -> _DatetimeT: ...
127127
def astimezone(self: _DatetimeT, tz: _tzinfo | None = ...) -> _DatetimeT: ...
128128
def ctime(self) -> str: ...
129129
def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...

pandas/core/arrays/masked.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ def equals(self, other) -> bool:
957957
return array_equivalent(left, right, dtype_equal=True)
958958

959959
def _quantile(
960-
self: BaseMaskedArrayT, qs: npt.NDArray[np.float64], interpolation: str
960+
self, qs: npt.NDArray[np.float64], interpolation: str
961961
) -> BaseMaskedArray:
962962
"""
963963
Dispatch to quantile_with_mask, needed because we do not have

pandas/io/parsers/base_parser.py

+8-17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from enum import Enum
88
import itertools
99
from typing import (
10+
Any,
1011
Callable,
1112
DefaultDict,
1213
Hashable,
@@ -1027,26 +1028,14 @@ def _get_empty_meta(
10271028
# Convert `dtype` to a defaultdict of some kind.
10281029
# This will enable us to write `dtype[col_name]`
10291030
# without worrying about KeyError issues later on.
1031+
dtype_dict: defaultdict[Hashable, Any]
10301032
if not is_dict_like(dtype):
10311033
# if dtype == None, default will be object.
10321034
default_dtype = dtype or object
1033-
# error: Argument 1 to "defaultdict" has incompatible type "Callable[[],
1034-
# Union[ExtensionDtype, str, dtype[Any], Type[object], Dict[Hashable,
1035-
# Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float],
1036-
# Type[int], Type[complex], Type[bool], Type[object]]]]]"; expected
1037-
# "Optional[Callable[[], Union[ExtensionDtype, str, dtype[Any],
1038-
# Type[object]]]]"
1039-
# error: Incompatible return value type (got "Union[ExtensionDtype, str,
1040-
# dtype[Any], Type[object], Dict[Hashable, Union[ExtensionDtype, Union[str,
1041-
# dtype[Any]], Type[str], Type[float], Type[int], Type[complex], Type[bool],
1042-
# Type[object]]]]", expected "Union[ExtensionDtype, str, dtype[Any],
1043-
# Type[object]]")
1044-
dtype = defaultdict(
1045-
lambda: default_dtype # type: ignore[arg-type, return-value]
1046-
)
1035+
dtype_dict = defaultdict(lambda: default_dtype)
10471036
else:
10481037
dtype = cast(dict, dtype)
1049-
dtype = defaultdict(
1038+
dtype_dict = defaultdict(
10501039
lambda: object,
10511040
{columns[k] if is_integer(k) else k: v for k, v in dtype.items()},
10521041
)
@@ -1063,14 +1052,16 @@ def _get_empty_meta(
10631052
if (index_col is None or index_col is False) or index_names is None:
10641053
index = Index([])
10651054
else:
1066-
data = [Series([], dtype=dtype[name]) for name in index_names]
1055+
data = [Series([], dtype=dtype_dict[name]) for name in index_names]
10671056
index = ensure_index_from_sequences(data, names=index_names)
10681057
index_col.sort()
10691058

10701059
for i, n in enumerate(index_col):
10711060
columns.pop(n - i)
10721061

1073-
col_dict = {col_name: Series([], dtype=dtype[col_name]) for col_name in columns}
1062+
col_dict = {
1063+
col_name: Series([], dtype=dtype_dict[col_name]) for col_name in columns
1064+
}
10741065

10751066
return index, columns, col_dict
10761067

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ flake8==4.0.1
1212
flake8-bugbear==21.3.2
1313
flake8-comprehensions==3.7.0
1414
isort>=5.2.1
15-
mypy==0.941
15+
mypy==0.950
1616
pre-commit>=2.9.2
1717
pycodestyle
1818
pyupgrade

0 commit comments

Comments
 (0)