Skip to content

TYP: Fix typehints for ExtensionDtype #41097

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 2 commits into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import (
TYPE_CHECKING,
Any,
TypeVar,
)

import numpy as np
Expand All @@ -26,6 +27,9 @@
if TYPE_CHECKING:
from pandas.core.arrays import ExtensionArray

# To parameterize on same ExtensionDtype
E = TypeVar("E", bound="ExtensionDtype")


class ExtensionDtype:
"""
Expand Down Expand Up @@ -151,7 +155,7 @@ def na_value(self) -> object:
return np.nan

@property
def type(self) -> type[Any]:
def type(self) -> type_t[Any]:
"""
The scalar type for the array, e.g. ``int``

Expand Down Expand Up @@ -364,7 +368,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
return None


def register_extension_dtype(cls: type[ExtensionDtype]) -> type[ExtensionDtype]:
def register_extension_dtype(cls: type[E]) -> type[E]:
"""
Register an ExtensionType with pandas as class decorator.

Expand Down