diff --git a/pandas/core/describe.py b/pandas/core/describe.py index 6623440e68551..fd45da4a3ccc7 100644 --- a/pandas/core/describe.py +++ b/pandas/core/describe.py @@ -13,6 +13,7 @@ TYPE_CHECKING, Any, Callable, + Hashable, Sequence, cast, ) @@ -21,10 +22,7 @@ import numpy as np from pandas._libs.tslibs import Timestamp -from pandas._typing import ( - FrameOrSeries, - Hashable, -) +from pandas._typing import FrameOrSeries from pandas.util._validators import validate_percentile from pandas.core.dtypes.common import ( diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 34b9a3f1f14ad..bda7584449983 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -20,7 +20,6 @@ from pandas._typing import ( ArrayLike, DtypeObj, - Optional, ) from pandas.core.dtypes.base import _registry as registry @@ -1406,7 +1405,7 @@ def is_1d_only_ea_obj(obj: Any) -> bool: ) -def is_1d_only_ea_dtype(dtype: Optional[DtypeObj]) -> bool: +def is_1d_only_ea_dtype(dtype: DtypeObj | None) -> bool: """ Analogue to is_extension_array_dtype but excluding DatetimeTZDtype. """ @@ -1471,7 +1470,7 @@ def is_extension_array_dtype(arr_or_dtype) -> bool: return registry.find(dtype) is not None -def is_ea_or_datetimelike_dtype(dtype: Optional[DtypeObj]) -> bool: +def is_ea_or_datetimelike_dtype(dtype: DtypeObj | None) -> bool: """ Check for ExtensionDtype, datetime64 dtype, or timedelta64 dtype. @@ -1715,7 +1714,7 @@ def _validate_date_like_dtype(dtype) -> None: ) -def validate_all_hashable(*args, error_name: Optional[str] = None) -> None: +def validate_all_hashable(*args, error_name: str | None = None) -> None: """ Return None if all args are hashable, else raise a TypeError. diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 10a8d18902035..fcca44d339711 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -68,6 +68,8 @@ Scalar, StorageOptions, Suffixes, + TimedeltaConvertibleTypes, + TimestampConvertibleTypes, ValueKeyFunc, npt, ) @@ -209,11 +211,6 @@ if TYPE_CHECKING: - from pandas._typing import ( - TimedeltaConvertibleTypes, - TimestampConvertibleTypes, - ) - from pandas.core.groupby.generic import DataFrameGroupBy from pandas.core.resample import Resampler diff --git a/pandas/core/indexers.py b/pandas/core/indexers.py index ef9b48911dfa1..eacc7960a82aa 100644 --- a/pandas/core/indexers.py +++ b/pandas/core/indexers.py @@ -3,13 +3,15 @@ """ from __future__ import annotations -from typing import TYPE_CHECKING +from typing import ( + TYPE_CHECKING, + Any, +) import warnings import numpy as np from pandas._typing import ( - Any, AnyArrayLike, ArrayLike, ) diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index e86fbab52fcf8..fef1d965eb534 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -7,6 +7,7 @@ from typing import ( TYPE_CHECKING, Any, + Callable, Sequence, TypeVar, cast, @@ -27,10 +28,7 @@ Tick, parsing, ) -from pandas._typing import ( - Callable, - final, -) +from pandas._typing import final from pandas.compat.numpy import function as nv from pandas.util._decorators import ( Appender, diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index b61554d38babf..023cb651c9632 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -9,10 +9,7 @@ Timedelta, to_offset, ) -from pandas._typing import ( - DtypeObj, - Optional, -) +from pandas._typing import DtypeObj from pandas.core.dtypes.common import ( TD64NS_DTYPE, @@ -233,7 +230,7 @@ def inferred_type(self) -> str: def timedelta_range( start=None, end=None, - periods: Optional[int] = None, + periods: int | None = None, freq=None, name=None, closed=None, diff --git a/pandas/core/internals/array_manager.py b/pandas/core/internals/array_manager.py index be61dd9f35216..51ea45ac18ce0 100644 --- a/pandas/core/internals/array_manager.py +++ b/pandas/core/internals/array_manager.py @@ -7,6 +7,7 @@ TYPE_CHECKING, Any, Callable, + Hashable, TypeVar, ) @@ -19,7 +20,6 @@ from pandas._typing import ( ArrayLike, DtypeObj, - Hashable, ) from pandas.util._validators import validate_bool_kwarg diff --git a/pandas/core/series.py b/pandas/core/series.py index 87d419d1f3d41..e61ce8e74629b 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -43,6 +43,8 @@ IndexKeyFunc, SingleManager, StorageOptions, + TimedeltaConvertibleTypes, + TimestampConvertibleTypes, ValueKeyFunc, npt, ) @@ -142,11 +144,6 @@ if TYPE_CHECKING: - from pandas._typing import ( - TimedeltaConvertibleTypes, - TimestampConvertibleTypes, - ) - from pandas.core.frame import DataFrame from pandas.core.groupby.generic import SeriesGroupBy from pandas.core.resample import Resampler