Skip to content

STY: Bump pyright, pyupgrade and mypy for new PEP-696 syntax #60006

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 4 commits into from
Oct 10, 2024

Conversation

mroeschke
Copy link
Member

Also bumps flake8 and pre-commit which should have innocuous changes

@mroeschke mroeschke added Code Style Code style, linting, code_checks Typing type annotations, mypy/pyright type checking labels Oct 9, 2024
@mroeschke mroeschke marked this pull request as ready for review October 9, 2024 21:44
@mroeschke mroeschke added this to the 3.0 milestone Oct 9, 2024
@@ -369,7 +369,7 @@ def _coerce_to_array(
assert dtype == "boolean"
return coerce_to_array(value, copy=copy)

def _logical_method(self, other, op):
def _logical_method(self, other, op): # type: ignore[override]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen a type-ignore on the signature of a function, do you know why this is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the mypy error

pandas/core/arrays/boolean.py:372: error: Signature of "_logical_method" incompatible with supertype "BaseMaskedArray"  [override]
pandas/core/arrays/boolean.py:372: note:      Superclass:
pandas/core/arrays/boolean.py:372: note:          def _arith_method(self: BaseMaskedArray, other: Any, op: Any) -> Any
pandas/core/arrays/boolean.py:372: note:      Subclass:
pandas/core/arrays/boolean.py:372: note:          def _logical_method(self, other: Any, op: Any) -> Any
pandas/core/arrays/boolean.py:372: note:      Superclass:
pandas/core/arrays/boolean.py:372: note:          def _arith_method(self: BaseMaskedArray, other: Any, op: Any) -> Any
pandas/core/arrays/boolean.py:372: note:      Subclass:
pandas/core/arrays/boolean.py:372: note:          def _logical_method(self, other: Any, op: Any) -> Any

In BasedMaskedArray we assign _logical_method = _arith_method, but override _logical_method in BooleanArray. It looks mypy is doing some inference on self even though we don't type it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think self is typed implicitly, yes. Makes sense that it's an override issue, thanks.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mroeschke mroeschke merged commit 2b9ca07 into pandas-dev:main Oct 10, 2024
51 checks passed
@mroeschke mroeschke deleted the deps/style/typingg branch October 10, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants