Skip to content

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
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