|
5 | 5 |
|
6 | 6 | if TYPE_CHECKING:
|
7 | 7 | from pandas import (
|
| 8 | + Categorical, |
8 | 9 | CategoricalIndex,
|
9 | 10 | DataFrame,
|
10 | 11 | DatetimeIndex,
|
|
19 | 20 | TimedeltaIndex,
|
20 | 21 | UInt64Index,
|
21 | 22 | )
|
| 23 | + from pandas.core.arrays import ( |
| 24 | + DatetimeArray, |
| 25 | + ExtensionArray, |
| 26 | + PandasArray, |
| 27 | + PeriodArray, |
| 28 | + TimedeltaArray, |
| 29 | + ) |
22 | 30 | from pandas.core.generic import NDFrame
|
23 | 31 |
|
24 | 32 |
|
@@ -111,16 +119,32 @@ def _check(cls, inst) -> bool:
|
111 | 119 | "Type[DataFrame]", create_pandas_abc_type("ABCDataFrame", "_typ", ("dataframe",))
|
112 | 120 | )
|
113 | 121 |
|
114 |
| -ABCCategorical = create_pandas_abc_type("ABCCategorical", "_typ", ("categorical")) |
115 |
| -ABCDatetimeArray = create_pandas_abc_type("ABCDatetimeArray", "_typ", ("datetimearray")) |
116 |
| -ABCTimedeltaArray = create_pandas_abc_type( |
117 |
| - "ABCTimedeltaArray", "_typ", ("timedeltaarray") |
118 |
| -) |
119 |
| -ABCPeriodArray = create_pandas_abc_type("ABCPeriodArray", "_typ", ("periodarray",)) |
120 |
| -ABCExtensionArray = create_pandas_abc_type( |
121 |
| - "ABCExtensionArray", |
122 |
| - "_typ", |
123 |
| - # Note: IntervalArray and SparseArray are included bc they have _typ="extension" |
124 |
| - {"extension", "categorical", "periodarray", "datetimearray", "timedeltaarray"}, |
125 |
| -) |
126 |
| -ABCPandasArray = create_pandas_abc_type("ABCPandasArray", "_typ", ("npy_extension",)) |
| 122 | +ABCCategorical = cast( |
| 123 | + "Type[Categorical]", |
| 124 | + create_pandas_abc_type("ABCCategorical", "_typ", ("categorical")), |
| 125 | +) |
| 126 | +ABCDatetimeArray = cast( |
| 127 | + "Type[DatetimeArray]", |
| 128 | + create_pandas_abc_type("ABCDatetimeArray", "_typ", ("datetimearray")), |
| 129 | +) |
| 130 | +ABCTimedeltaArray = cast( |
| 131 | + "Type[TimedeltaArray]", |
| 132 | + create_pandas_abc_type("ABCTimedeltaArray", "_typ", ("timedeltaarray")), |
| 133 | +) |
| 134 | +ABCPeriodArray = cast( |
| 135 | + "Type[PeriodArray]", |
| 136 | + create_pandas_abc_type("ABCPeriodArray", "_typ", ("periodarray",)), |
| 137 | +) |
| 138 | +ABCExtensionArray = cast( |
| 139 | + "Type[ExtensionArray]", |
| 140 | + create_pandas_abc_type( |
| 141 | + "ABCExtensionArray", |
| 142 | + "_typ", |
| 143 | + # Note: IntervalArray and SparseArray are included bc they have _typ="extension" |
| 144 | + {"extension", "categorical", "periodarray", "datetimearray", "timedeltaarray"}, |
| 145 | + ), |
| 146 | +) |
| 147 | +ABCPandasArray = cast( |
| 148 | + "Type[PandasArray]", |
| 149 | + create_pandas_abc_type("ABCPandasArray", "_typ", ("npy_extension",)), |
| 150 | +) |
0 commit comments