13
13
14
14
from pandas ._typing import (
15
15
DtypeObj ,
16
+ E ,
16
17
type_t ,
17
18
)
18
19
from pandas .errors import AbstractMethodError
@@ -151,7 +152,7 @@ def na_value(self) -> object:
151
152
return np .nan
152
153
153
154
@property
154
- def type (self ) -> type [Any ]:
155
+ def type (self ) -> type_t [Any ]:
155
156
"""
156
157
The scalar type for the array, e.g. ``int``
157
158
@@ -209,7 +210,7 @@ def construct_array_type(cls) -> type_t[ExtensionArray]:
209
210
raise NotImplementedError
210
211
211
212
@classmethod
212
- def construct_from_string (cls , string : str ):
213
+ def construct_from_string (cls , string : str ) -> ExtensionDtype :
213
214
r"""
214
215
Construct this type from a string.
215
216
@@ -364,7 +365,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
364
365
return None
365
366
366
367
367
- def register_extension_dtype (cls : type [ExtensionDtype ]) -> type [ExtensionDtype ]:
368
+ def register_extension_dtype (cls : type [E ]) -> type [E ]:
368
369
"""
369
370
Register an ExtensionType with pandas as class decorator.
370
371
@@ -420,7 +421,7 @@ def register(self, dtype: type[ExtensionDtype]) -> None:
420
421
421
422
self .dtypes .append (dtype )
422
423
423
- def find (self , dtype : type [ExtensionDtype ] | str ) -> type [ExtensionDtype ] | None :
424
+ def find (self , dtype : type [E ] | E | str ) -> type [E ] | E | ExtensionDtype | None :
424
425
"""
425
426
Parameters
426
427
----------
@@ -431,10 +432,7 @@ def find(self, dtype: type[ExtensionDtype] | str) -> type[ExtensionDtype] | None
431
432
return the first matching dtype, otherwise return None
432
433
"""
433
434
if not isinstance (dtype , str ):
434
- dtype_type = dtype
435
- if not isinstance (dtype , type ):
436
- dtype_type = type (dtype )
437
- if issubclass (dtype_type , ExtensionDtype ):
435
+ if isinstance (dtype , (ExtensionDtype , type (ExtensionDtype ))):
438
436
return dtype
439
437
440
438
return None
0 commit comments