Skip to content

TYP: incorrect array_finalize definition in ndarray for subclassing #20756

@henryiii

Description

@henryiii

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions