Skip to content

Conversation

jorisvandenbossche
Copy link
Member

Running into this in #61925, trying to fix this here separately (as I might have some questions for typing experts on how to get this passing, and don't want to derail the original PR for that)

@jorisvandenbossche jorisvandenbossche added the Typing type annotations, mypy/pyright type checking label Sep 7, 2025
Comment on lines -511 to 512

@overload
@overload # type: ignore[override]
def view(self) -> Self: ...
Copy link
Member Author

Choose a reason for hiding this comment

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

It's not really clear to me why I need to add this ignore here (since this is exactly the same as in the base class and the mixin base).

But if not adding it, I get

pandas/core/arrays/datetimelike.py:511: error: Signature of "view" incompatible with supertype "pandas.core.arrays._mixins.NDArrayBackedExtensionArray"  [override]
pandas/core/arrays/datetimelike.py:511: note:      Superclass:
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self) -> DatetimeLikeArrayMixin
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: ExtensionDtype | str | dtype[Any] | type[str] | type[complex] | type[bool] | type[object] | None = ...) -> ExtensionArray | ndarray[Any, Any]
pandas/core/arrays/datetimelike.py:511: note:      Subclass:
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self) -> DatetimeLikeArrayMixin
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: Literal['M8[ns]']) -> DatetimeArray
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: Literal['m8[ns]']) -> TimedeltaArray
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: ExtensionDtype | str | dtype[Any] | type[str] | type[complex] | type[bool] | type[object] | None = ...) -> ExtensionArray | ndarray[Any, Any]
pandas/core/arrays/datetimelike.py:511: error: Signature of "view" incompatible with supertype "pandas.core.arrays.base.ExtensionArray"  [override]
pandas/core/arrays/datetimelike.py:511: note:      Superclass:
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self) -> DatetimeLikeArrayMixin
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: ExtensionDtype | str | dtype[Any] | type[str] | type[complex] | type[bool] | type[object] | None = ...) -> ExtensionArray | ndarray[Any, Any]
pandas/core/arrays/datetimelike.py:511: note:      Subclass:
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self) -> DatetimeLikeArrayMixin
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: Literal['M8[ns]']) -> DatetimeArray
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: Literal['m8[ns]']) -> TimedeltaArray
pandas/core/arrays/datetimelike.py:511: note:          @overload
pandas/core/arrays/datetimelike.py:511: note:          def view(self, dtype: ExtensionDtype | str | dtype[Any] | type[str] | type[complex] | type[bool] | type[object] | None = ...) -> ExtensionArray | ndarray[Any, Any]

@mroeschke mroeschke added this to the 3.0 milestone Sep 8, 2025
@mroeschke mroeschke merged commit c316081 into pandas-dev:main Sep 8, 2025
38 checks passed
@mroeschke
Copy link
Member

Thanks @jorisvandenbossche

@jorisvandenbossche jorisvandenbossche deleted the typing-view branch September 8, 2025 19:26
eicchen pushed a commit to eicchen/pandas that referenced this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Typing type annotations, mypy/pyright type checking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants