diff --git a/pandas/core/ops/array_ops.py b/pandas/core/ops/array_ops.py index c0ab72e9d796b..87b3091fca75a 100644 --- a/pandas/core/ops/array_ops.py +++ b/pandas/core/ops/array_ops.py @@ -7,7 +7,10 @@ import datetime from functools import partial import operator -from typing import Any +from typing import ( + TYPE_CHECKING, + Any, +) import numpy as np @@ -19,10 +22,6 @@ ops as libops, ) from pandas._libs.tslibs import BaseOffset -from pandas._typing import ( - ArrayLike, - Shape, -) from pandas.core.dtypes.cast import ( construct_1d_object_array_from_listlike, @@ -54,6 +53,12 @@ from pandas.core.ops.dispatch import should_extension_dispatch from pandas.core.ops.invalid import invalid_comparison +if TYPE_CHECKING: + from pandas._typing import ( + ArrayLike, + Shape, + ) + # ----------------------------------------------------------------------------- # Masking NA values and fallbacks for operations numpy does not support diff --git a/pandas/core/ops/common.py b/pandas/core/ops/common.py index d4ae143372271..01fb9aa17fc48 100644 --- a/pandas/core/ops/common.py +++ b/pandas/core/ops/common.py @@ -5,11 +5,13 @@ from functools import wraps import sys -from typing import Callable +from typing import ( + TYPE_CHECKING, + Callable, +) from pandas._libs.lib import item_from_zerodim from pandas._libs.missing import is_matching_na -from pandas._typing import F from pandas.core.dtypes.generic import ( ABCDataFrame, @@ -17,6 +19,9 @@ ABCSeries, ) +if TYPE_CHECKING: + from pandas._typing import F + def unpack_zerodim_and_defer(name: str) -> Callable[[F], F]: """ diff --git a/pandas/core/ops/dispatch.py b/pandas/core/ops/dispatch.py index 2f500703ccfb3..a939fdd3d041e 100644 --- a/pandas/core/ops/dispatch.py +++ b/pandas/core/ops/dispatch.py @@ -3,12 +3,16 @@ """ from __future__ import annotations -from typing import Any - -from pandas._typing import ArrayLike +from typing import ( + TYPE_CHECKING, + Any, +) from pandas.core.dtypes.generic import ABCExtensionArray +if TYPE_CHECKING: + from pandas._typing import ArrayLike + def should_extension_dispatch(left: ArrayLike, right: Any) -> bool: """ diff --git a/pandas/core/sorting.py b/pandas/core/sorting.py index 1430dd22c32db..d6adf01f4e12b 100644 --- a/pandas/core/sorting.py +++ b/pandas/core/sorting.py @@ -20,15 +20,6 @@ lib, ) from pandas._libs.hashtable import unique_label_indices -from pandas._typing import ( - AxisInt, - IndexKeyFunc, - Level, - NaPosition, - Shape, - SortKind, - npt, -) from pandas.core.dtypes.common import ( ensure_int64, @@ -44,6 +35,16 @@ from pandas.core.construction import extract_array if TYPE_CHECKING: + from pandas._typing import ( + AxisInt, + IndexKeyFunc, + Level, + NaPosition, + Shape, + SortKind, + npt, + ) + from pandas import MultiIndex from pandas.core.arrays import ExtensionArray from pandas.core.indexes.base import Index diff --git a/pyproject.toml b/pyproject.toml index 00fcf1eb06d4e..c5c9cd702a380 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -295,11 +295,6 @@ exclude = [ # TCH to be enabled gradually "pandas/core/arrays/*" = ["TCH"] "pandas/core/nanops.py" = ["TCH"] -"pandas/core/apply.py" = ["TCH"] -"pandas/core/base.py" = ["TCH"] -"pandas/core/algorithms.py" = ["TCH"] -"pandas/core/ops/*" = ["TCH"] -"pandas/core/sorting.py" = ["TCH"] "pandas/util/*" = ["TCH"] "pandas/_libs/*" = ["TCH"] # Keep this one enabled