Skip to content

CI: bump mypy&pyright #46411

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 1 commit into from
Mar 18, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:

- name: Install pyright
# note: keep version in sync with .pre-commit-config.yaml
run: npm install -g [email protected].212
run: npm install -g [email protected].230

- name: Build Pandas
id: build
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ repos:
types: [python]
stages: [manual]
# note: keep version in sync with .github/workflows/code-checks.yml
additional_dependencies: ['[email protected].212']
additional_dependencies: ['[email protected].230']
- repo: local
hooks:
- id: flake8-rst
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ If installed, we now require:
+-----------------+-----------------+----------+---------+
| Package | Minimum Version | Required | Changed |
+=================+=================+==========+=========+
| mypy (dev) | 0.931 | | X |
| mypy (dev) | 0.941 | | X |
+-----------------+-----------------+----------+---------+


Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- flake8-bugbear=21.3.2 # used by flake8, find likely bugs
- flake8-comprehensions=3.7.0 # used by flake8, linting of unnecessary comprehensions
- isort>=5.2.1 # check that imports are in the right order
- mypy=0.931
- mypy=0.941
- pre-commit>=2.9.2
- pycodestyle # used by flake8
- pyupgrade
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,7 @@ def fillna(
elif method is not None:
msg = "fillna with 'method' requires high memory usage."
warnings.warn(msg, PerformanceWarning)
# Need type annotation for "new_values" [var-annotated]
new_values = np.asarray(self) # type: ignore[var-annotated]
new_values = np.asarray(self)
# interpolate_2d modifies new_values inplace
interpolate_2d(new_values, method=method, limit=limit)
return type(self)(new_values, fill_value=self.fill_value)
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/computation/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ def __init__(self, op: str, operand) -> None:

def __call__(self, env):
operand = self.operand(env)
return self.func(operand)
# error: Cannot call function of unknown type
return self.func(operand) # type: ignore[operator]

def __repr__(self) -> str:
return pprint_thing(f"{self.op}({self.operand})")
Expand Down
15 changes: 12 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,9 +1481,15 @@ def equals(self, other: object) -> bool_t:
def __neg__(self):
def blk_func(values: ArrayLike):
if is_bool_dtype(values.dtype):
return operator.inv(values)
# error: Argument 1 to "inv" has incompatible type "Union
# [ExtensionArray, ndarray[Any, Any]]"; expected
# "_SupportsInversion[ndarray[Any, dtype[bool_]]]"
return operator.inv(values) # type: ignore[arg-type]
else:
return operator.neg(values)
# error: Argument 1 to "neg" has incompatible type "Union
# [ExtensionArray, ndarray[Any, Any]]"; expected
# "_SupportsNeg[ndarray[Any, dtype[Any]]]"
return operator.neg(values) # type: ignore[arg-type]

new_data = self._mgr.apply(blk_func)
res = self._constructor(new_data)
Expand All @@ -1495,7 +1501,10 @@ def blk_func(values: ArrayLike):
if is_bool_dtype(values.dtype):
return values.copy()
else:
return operator.pos(values)
# error: Argument 1 to "pos" has incompatible type "Union
# [ExtensionArray, ndarray[Any, Any]]"; expected
# "_SupportsPos[ndarray[Any, dtype[Any]]]"
return operator.pos(values) # type: ignore[arg-type]

new_data = self._mgr.apply(blk_func)
res = self._constructor(new_data)
Expand Down
6 changes: 5 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4088,7 +4088,11 @@ def _get_nearest_indexer(

op = operator.lt if self.is_monotonic_increasing else operator.le
indexer = np.where(
op(left_distances, right_distances) | (right_indexer == -1),
# error: Argument 1&2 has incompatible type "Union[ExtensionArray,
# ndarray[Any, Any]]"; expected "Union[SupportsDunderLE,
# SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"
op(left_distances, right_distances) # type: ignore[arg-type]
| (right_indexer == -1),
left_indexer,
right_indexer,
)
Expand Down
12 changes: 10 additions & 2 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -3875,14 +3875,22 @@ def _highlight_between(
)

g_left = (
ops[0](data, left)
# error: Argument 2 to "ge" has incompatible type "Union[str, float,
# Period, Timedelta, Interval[Any], datetime64, timedelta64, datetime,
# Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union
# [SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"
ops[0](data, left) # type: ignore[arg-type]
if left is not None
else np.full(data.shape, True, dtype=bool)
)
if isinstance(g_left, (DataFrame, Series)):
g_left = g_left.where(pd.notna(g_left), False)
l_right = (
ops[1](data, right)
# error: Argument 2 to "le" has incompatible type "Union[str, float,
# Period, Timedelta, Interval[Any], datetime64, timedelta64, datetime,
# Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union
# [SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"
ops[1](data, right) # type: ignore[arg-type]
if right is not None
else np.full(data.shape, True, dtype=bool)
)
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ flake8==4.0.1
flake8-bugbear==21.3.2
flake8-comprehensions==3.7.0
isort>=5.2.1
mypy==0.931
mypy==0.941
pre-commit>=2.9.2
pycodestyle
pyupgrade
Expand Down