Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TYP: incorrect array_finalize definition in ndarray for subclassing #20756

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

Closed
henryiii opened this issue Jan 6, 2022 · 2 comments · Fixed by #20768
Closed

TYP: incorrect array_finalize definition in ndarray for subclassing #20756

henryiii opened this issue Jan 6, 2022 · 2 comments · Fixed by #20768

Comments

@henryiii
Copy link
Contributor

henryiii commented Jan 6, 2022

numpy/numpy/__init__.pyi

Lines 1505 to 1506 in 4adc87d

@property
def __array_finalize__(self) -> None: ...

Currently, mypy does not allow users to define __array_finalize__, since the super class (ndarray) does not have an argument. So the following error is produced:

src/vector/_backends/numpy_.py:899: error: Signature of "__array_finalize__" incompatible with supertype "ndarray"  [override]
src/vector/_backends/numpy_.py:899: note:      Superclass:
src/vector/_backends/numpy_.py:899: note:          def __array_finalize__(self) -> None
src/vector/_backends/numpy_.py:899: note:      Subclass:
src/vector/_backends/numpy_.py:899: note:          def __array_finalize__(self, obj: Any) -> None

This type stub should have a obj: Any argument.

@BvB93 BvB93 changed the title TYPING: incorrect array_finalize definition in ndarray for subclassing TYP: incorrect array_finalize definition in ndarray for subclassing Jan 7, 2022
@BvB93
Copy link
Member

BvB93 commented Jan 7, 2022

This seems to be a duplicate of #20764 (though the focus of that issue is admittedly a bit broader).
In any case, PR #20764 will resolve the issue.

@BvB93
Copy link
Member

BvB93 commented Jan 8, 2022

Closed by #20768

@BvB93 BvB93 closed this as completed Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants