Skip to content

Commit 76c242d

Browse files
authored
TYP: NumericDtype._standardize_dtype (#47298)
1 parent 3c100a5 commit 76c242d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/core/arrays/numeric.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
TYPE_CHECKING,
66
Any,
77
Callable,
8+
Mapping,
89
TypeVar,
910
)
1011

@@ -113,11 +114,11 @@ def __from_arrow__(
113114
return array_class._concat_same_type(results)
114115

115116
@classmethod
116-
def _str_to_dtype_mapping(cls):
117+
def _str_to_dtype_mapping(cls) -> Mapping[str, NumericDtype]:
117118
raise AbstractMethodError(cls)
118119

119120
@classmethod
120-
def _standardize_dtype(cls, dtype) -> NumericDtype:
121+
def _standardize_dtype(cls, dtype: NumericDtype | str | np.dtype) -> NumericDtype:
121122
"""
122123
Convert a string representation or a numpy dtype to NumericDtype.
123124
"""
@@ -126,7 +127,7 @@ def _standardize_dtype(cls, dtype) -> NumericDtype:
126127
# https://github.com/numpy/numpy/pull/7476
127128
dtype = dtype.lower()
128129

129-
if not issubclass(type(dtype), cls):
130+
if not isinstance(dtype, NumericDtype):
130131
mapping = cls._str_to_dtype_mapping()
131132
try:
132133
dtype = mapping[str(np.dtype(dtype))]

pyright_reportGeneralTypeIssues.json

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"pandas/core/arrays/datetimes.py",
2929
"pandas/core/arrays/interval.py",
3030
"pandas/core/arrays/masked.py",
31-
"pandas/core/arrays/numeric.py",
3231
"pandas/core/arrays/period.py",
3332
"pandas/core/arrays/sparse/array.py",
3433
"pandas/core/arrays/sparse/dtype.py",

0 commit comments

Comments
 (0)