diff --git a/pandas/core/dtypes/base.py b/pandas/core/dtypes/base.py index 8104b0170fbe2..9671c340a0a92 100644 --- a/pandas/core/dtypes/base.py +++ b/pandas/core/dtypes/base.py @@ -7,6 +7,7 @@ from typing import ( TYPE_CHECKING, Any, + TypeVar, ) import numpy as np @@ -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: """ @@ -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`` @@ -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.