Skip to content

Commit 975c22e

Browse files
ozarsyeshsurya
authored andcommitted
TYP: Fix typehints for ExtensionDtype (pandas-dev#41097)
1 parent a396bd2 commit 975c22e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/core/dtypes/base.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import (
88
TYPE_CHECKING,
99
Any,
10+
TypeVar,
1011
)
1112

1213
import numpy as np
@@ -26,6 +27,9 @@
2627
if TYPE_CHECKING:
2728
from pandas.core.arrays import ExtensionArray
2829

30+
# To parameterize on same ExtensionDtype
31+
E = TypeVar("E", bound="ExtensionDtype")
32+
2933

3034
class ExtensionDtype:
3135
"""
@@ -151,7 +155,7 @@ def na_value(self) -> object:
151155
return np.nan
152156

153157
@property
154-
def type(self) -> type[Any]:
158+
def type(self) -> type_t[Any]:
155159
"""
156160
The scalar type for the array, e.g. ``int``
157161
@@ -364,7 +368,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
364368
return None
365369

366370

367-
def register_extension_dtype(cls: type[ExtensionDtype]) -> type[ExtensionDtype]:
371+
def register_extension_dtype(cls: type[E]) -> type[E]:
368372
"""
369373
Register an ExtensionType with pandas as class decorator.
370374

0 commit comments

Comments
 (0)