@@ -1827,7 +1827,10 @@ def _get_dtype(arr_or_dtype):
1827
1827
if isinstance (arr_or_dtype , np .dtype ):
1828
1828
return arr_or_dtype
1829
1829
elif isinstance (arr_or_dtype , type ):
1830
- return np .dtype (arr_or_dtype )
1830
+ try :
1831
+ return pandas_dtype (arr_or_dtype )
1832
+ except TypeError :
1833
+ return np .dtype (arr_or_dtype )
1831
1834
elif isinstance (arr_or_dtype , ExtensionDtype ):
1832
1835
return arr_or_dtype
1833
1836
elif isinstance (arr_or_dtype , DatetimeTZDtype ):
@@ -1845,6 +1848,11 @@ def _get_dtype(arr_or_dtype):
1845
1848
return PeriodDtype .construct_from_string (arr_or_dtype )
1846
1849
elif is_interval_dtype (arr_or_dtype ):
1847
1850
return IntervalDtype .construct_from_string (arr_or_dtype )
1851
+ else :
1852
+ try :
1853
+ return pandas_dtype (arr_or_dtype )
1854
+ except TypeError :
1855
+ pass
1848
1856
elif isinstance (arr_or_dtype , (ABCCategorical , ABCCategoricalIndex ,
1849
1857
ABCSparseArray , ABCSparseSeries )):
1850
1858
return arr_or_dtype .dtype
@@ -1875,7 +1883,15 @@ def _get_dtype_type(arr_or_dtype):
1875
1883
if isinstance (arr_or_dtype , np .dtype ):
1876
1884
return arr_or_dtype .type
1877
1885
elif isinstance (arr_or_dtype , type ):
1878
- return np .dtype (arr_or_dtype ).type
1886
+ try :
1887
+ dtype = pandas_dtype (arr_or_dtype )
1888
+ try :
1889
+ return dtype .type
1890
+ except AttributeError :
1891
+ raise TypeError
1892
+ except TypeError :
1893
+ return np .dtype (arr_or_dtype ).type
1894
+
1879
1895
elif isinstance (arr_or_dtype , CategoricalDtype ):
1880
1896
return CategoricalDtypeType
1881
1897
elif isinstance (arr_or_dtype , DatetimeTZDtype ):
0 commit comments