|
75 | 75 | from pandas.core.dtypes.inference import is_list_like
|
76 | 76 | from pandas.core.dtypes.missing import is_valid_nat_for_dtype, isna, notna
|
77 | 77 |
|
| 78 | +from pandas.core.indexes.datetimes import DatetimeIndex |
| 79 | + |
78 | 80 | if TYPE_CHECKING:
|
79 | 81 | from pandas import Series
|
80 | 82 | from pandas.core.arrays import ExtensionArray
|
@@ -181,7 +183,7 @@ def maybe_downcast_to_dtype(result, dtype: Dtype):
|
181 | 183 | return result
|
182 | 184 |
|
183 | 185 |
|
184 |
| -def maybe_downcast_numeric(result, dtype: Dtype, do_round: bool = False): |
| 186 | +def maybe_downcast_numeric(result, dtype: DtypeObj, do_round: bool = False): |
185 | 187 | """
|
186 | 188 | Subset of maybe_downcast_to_dtype restricted to numeric dtypes.
|
187 | 189 |
|
@@ -325,8 +327,8 @@ def maybe_cast_result_dtype(dtype: DtypeObj, how: str) -> DtypeObj:
|
325 | 327 |
|
326 | 328 |
|
327 | 329 | def maybe_cast_to_extension_array(
|
328 |
| - cls: Type["ExtensionArray"], obj, dtype: Dtype = None |
329 |
| -): |
| 330 | + cls: Type["ExtensionArray"], obj: ArrayLike, dtype: Optional[ExtensionDtype] = None |
| 331 | +) -> ArrayLike: |
330 | 332 | """
|
331 | 333 | Call to `_from_sequence` that returns the object unchanged on Exception.
|
332 | 334 |
|
@@ -728,7 +730,7 @@ def infer_dtype_from_scalar(val, pandas_dtype: bool = False) -> Tuple[DtypeObj,
|
728 | 730 | # TODO: try to make the Any in the return annotation more specific
|
729 | 731 | def infer_dtype_from_array(
|
730 | 732 | arr, pandas_dtype: bool = False
|
731 |
| -) -> Tuple[DtypeObj, AnyArrayLike]: |
| 733 | +) -> Tuple[DtypeObj, ArrayLike]: |
732 | 734 | """
|
733 | 735 | Infer the dtype from an array.
|
734 | 736 |
|
@@ -1018,7 +1020,7 @@ def astype_nansafe(
|
1018 | 1020 |
|
1019 | 1021 | def maybe_convert_objects(
|
1020 | 1022 | values: np.ndarray, convert_numeric: bool = True
|
1021 |
| -) -> Union[np.ndarray, ABCDatetimeIndex]: |
| 1023 | +) -> Union[np.ndarray, DatetimeIndex]: |
1022 | 1024 | """
|
1023 | 1025 | If we have an object dtype array, try to coerce dates and/or numbers.
|
1024 | 1026 |
|
|
0 commit comments