Skip to content

Commit 2404f3d

Browse files
narrow the check, want only np types
1 parent 6f40d3d commit 2404f3d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pandas/core/dtypes/common.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Common type operations.
33
"""
44
from __future__ import annotations
5-
import inspect
65

6+
import inspect
77
from typing import (
88
Any,
99
Callable,
@@ -31,7 +31,6 @@
3131
DatetimeTZDtype,
3232
ExtensionDtype,
3333
IntervalDtype,
34-
PandasExtensionDtype,
3534
PeriodDtype,
3635
)
3736
from pandas.core.dtypes.generic import (
@@ -1576,9 +1575,8 @@ def get_dtype(arr_or_dtype) -> DtypeObj:
15761575
# fastpath
15771576
elif isinstance(arr_or_dtype, np.dtype):
15781577
return arr_or_dtype
1579-
elif isinstance(arr_or_dtype, type):
1578+
elif inspect.isclass(arr_or_dtype) and issubclass(arr_or_dtype, np.generic):
15801579
return np.dtype(arr_or_dtype)
1581-
15821580
# if we have an array-like
15831581
elif hasattr(arr_or_dtype, "dtype"):
15841582
arr_or_dtype = arr_or_dtype.dtype

0 commit comments

Comments
 (0)