Skip to content

Commit f469af7

Browse files
authored
CI: bump mypy&pyright (#46411)
1 parent 2278923 commit f469af7

File tree

10 files changed

+35
-14
lines changed

10 files changed

+35
-14
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].212
77+
run: npm install -g [email protected].230
7878

7979
- name: Build Pandas
8080
id: build

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ repos:
8585
types: [python]
8686
stages: [manual]
8787
# note: keep version in sync with .github/workflows/code-checks.yml
88-
additional_dependencies: ['[email protected].212']
88+
additional_dependencies: ['[email protected].230']
8989
- repo: local
9090
hooks:
9191
- id: flake8-rst

doc/source/whatsnew/v1.5.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ If installed, we now require:
177177
+-----------------+-----------------+----------+---------+
178178
| Package | Minimum Version | Required | Changed |
179179
+=================+=================+==========+=========+
180-
| mypy (dev) | 0.931 | | X |
180+
| mypy (dev) | 0.941 | | X |
181181
+-----------------+-----------------+----------+---------+
182182

183183

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.931
27+
- mypy=0.941
2828
- pre-commit>=2.9.2
2929
- pycodestyle # used by flake8
3030
- pyupgrade

pandas/core/arrays/sparse/array.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,7 @@ def fillna(
774774
elif method is not None:
775775
msg = "fillna with 'method' requires high memory usage."
776776
warnings.warn(msg, PerformanceWarning)
777-
# Need type annotation for "new_values" [var-annotated]
778-
new_values = np.asarray(self) # type: ignore[var-annotated]
777+
new_values = np.asarray(self)
779778
# interpolate_2d modifies new_values inplace
780779
interpolate_2d(new_values, method=method, limit=limit)
781780
return type(self)(new_values, fill_value=self.fill_value)

pandas/core/computation/ops.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ def __init__(self, op: str, operand) -> None:
580580

581581
def __call__(self, env):
582582
operand = self.operand(env)
583-
return self.func(operand)
583+
# error: Cannot call function of unknown type
584+
return self.func(operand) # type: ignore[operator]
584585

585586
def __repr__(self) -> str:
586587
return pprint_thing(f"{self.op}({self.operand})")

pandas/core/generic.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1481,9 +1481,15 @@ def equals(self, other: object) -> bool_t:
14811481
def __neg__(self):
14821482
def blk_func(values: ArrayLike):
14831483
if is_bool_dtype(values.dtype):
1484-
return operator.inv(values)
1484+
# error: Argument 1 to "inv" has incompatible type "Union
1485+
# [ExtensionArray, ndarray[Any, Any]]"; expected
1486+
# "_SupportsInversion[ndarray[Any, dtype[bool_]]]"
1487+
return operator.inv(values) # type: ignore[arg-type]
14851488
else:
1486-
return operator.neg(values)
1489+
# error: Argument 1 to "neg" has incompatible type "Union
1490+
# [ExtensionArray, ndarray[Any, Any]]"; expected
1491+
# "_SupportsNeg[ndarray[Any, dtype[Any]]]"
1492+
return operator.neg(values) # type: ignore[arg-type]
14871493

14881494
new_data = self._mgr.apply(blk_func)
14891495
res = self._constructor(new_data)
@@ -1495,7 +1501,10 @@ def blk_func(values: ArrayLike):
14951501
if is_bool_dtype(values.dtype):
14961502
return values.copy()
14971503
else:
1498-
return operator.pos(values)
1504+
# error: Argument 1 to "pos" has incompatible type "Union
1505+
# [ExtensionArray, ndarray[Any, Any]]"; expected
1506+
# "_SupportsPos[ndarray[Any, dtype[Any]]]"
1507+
return operator.pos(values) # type: ignore[arg-type]
14991508

15001509
new_data = self._mgr.apply(blk_func)
15011510
res = self._constructor(new_data)

pandas/core/indexes/base.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -4088,7 +4088,11 @@ def _get_nearest_indexer(
40884088

40894089
op = operator.lt if self.is_monotonic_increasing else operator.le
40904090
indexer = np.where(
4091-
op(left_distances, right_distances) | (right_indexer == -1),
4091+
# error: Argument 1&2 has incompatible type "Union[ExtensionArray,
4092+
# ndarray[Any, Any]]"; expected "Union[SupportsDunderLE,
4093+
# SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"
4094+
op(left_distances, right_distances) # type: ignore[arg-type]
4095+
| (right_indexer == -1),
40924096
left_indexer,
40934097
right_indexer,
40944098
)

pandas/io/formats/style.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -3875,14 +3875,22 @@ def _highlight_between(
38753875
)
38763876

38773877
g_left = (
3878-
ops[0](data, left)
3878+
# error: Argument 2 to "ge" has incompatible type "Union[str, float,
3879+
# Period, Timedelta, Interval[Any], datetime64, timedelta64, datetime,
3880+
# Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union
3881+
# [SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"
3882+
ops[0](data, left) # type: ignore[arg-type]
38793883
if left is not None
38803884
else np.full(data.shape, True, dtype=bool)
38813885
)
38823886
if isinstance(g_left, (DataFrame, Series)):
38833887
g_left = g_left.where(pd.notna(g_left), False)
38843888
l_right = (
3885-
ops[1](data, right)
3889+
# error: Argument 2 to "le" has incompatible type "Union[str, float,
3890+
# Period, Timedelta, Interval[Any], datetime64, timedelta64, datetime,
3891+
# Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union
3892+
# [SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"
3893+
ops[1](data, right) # type: ignore[arg-type]
38863894
if right is not None
38873895
else np.full(data.shape, True, dtype=bool)
38883896
)

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.931
15+
mypy==0.941
1616
pre-commit>=2.9.2
1717
pycodestyle
1818
pyupgrade

0 commit comments

Comments
 (0)