Skip to content

Commit 48fb5e0

Browse files
committed
Enabled ruff TCH on pandas/core/apply.py, pandas/core/base.py, pandas/core/algorithms.py,
pandas/core/sorting.py and pandas/core/ops/*. Only for the last two items there were changes needed.
1 parent c71645f commit 48fb5e0

File tree

6 files changed

+39
-29
lines changed

6 files changed

+39
-29
lines changed

pandas/core/ops/__init__.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
import numpy as np
1515

1616
from pandas._libs.ops_dispatch import maybe_dispatch_ufunc_to_dunder_op
17-
from pandas._typing import (
18-
Axis,
19-
AxisInt,
20-
Level,
21-
)
17+
2218
from pandas.util._decorators import Appender
2319

2420
from pandas.core.dtypes.common import (
@@ -79,6 +75,11 @@
7975
DataFrame,
8076
Series,
8177
)
78+
from pandas._typing import (
79+
Axis,
80+
AxisInt,
81+
Level,
82+
)
8283

8384
# -----------------------------------------------------------------------------
8485
# constants

pandas/core/ops/array_ops.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import datetime
88
from functools import partial
99
import operator
10-
from typing import Any
10+
from typing import (
11+
TYPE_CHECKING,
12+
Any
13+
)
1114

1215
import numpy as np
1316

@@ -19,10 +22,6 @@
1922
ops as libops,
2023
)
2124
from pandas._libs.tslibs import BaseOffset
22-
from pandas._typing import (
23-
ArrayLike,
24-
Shape,
25-
)
2625

2726
from pandas.core.dtypes.cast import (
2827
construct_1d_object_array_from_listlike,
@@ -56,6 +55,12 @@
5655
from pandas.core.ops.dispatch import should_extension_dispatch
5756
from pandas.core.ops.invalid import invalid_comparison
5857

58+
if TYPE_CHECKING:
59+
from pandas._typing import (
60+
ArrayLike,
61+
Shape,
62+
)
63+
5964

6065
def comp_method_OBJECT_ARRAY(op, x, y):
6166
if isinstance(y, list):

pandas/core/ops/common.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55

66
from functools import wraps
77
import sys
8-
from typing import Callable
8+
from typing import (
9+
TYPE_CHECKING,
10+
Callable
11+
)
912

1013
from pandas._libs.lib import item_from_zerodim
1114
from pandas._libs.missing import is_matching_na
12-
from pandas._typing import F
1315

1416
from pandas.core.dtypes.generic import (
1517
ABCDataFrame,
1618
ABCIndex,
1719
ABCSeries,
1820
)
1921

22+
if TYPE_CHECKING:
23+
from pandas._typing import F
24+
2025

2126
def unpack_zerodim_and_defer(name: str) -> Callable[[F], F]:
2227
"""

pandas/core/ops/dispatch.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
"""
44
from __future__ import annotations
55

6-
from typing import Any
7-
8-
from pandas._typing import ArrayLike
6+
from typing import (
7+
TYPE_CHECKING,
8+
Any
9+
)
910

1011
from pandas.core.dtypes.generic import ABCExtensionArray
1112

13+
if TYPE_CHECKING:
14+
from pandas._typing import ArrayLike
15+
1216

1317
def should_extension_dispatch(left: ArrayLike, right: Any) -> bool:
1418
"""

pandas/core/sorting.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@
2020
lib,
2121
)
2222
from pandas._libs.hashtable import unique_label_indices
23-
from pandas._typing import (
24-
AxisInt,
25-
IndexKeyFunc,
26-
Level,
27-
NaPosition,
28-
Shape,
29-
SortKind,
30-
npt,
31-
)
3223

3324
from pandas.core.dtypes.common import (
3425
ensure_int64,
@@ -47,6 +38,15 @@
4738
from pandas import MultiIndex
4839
from pandas.core.arrays import ExtensionArray
4940
from pandas.core.indexes.base import Index
41+
from pandas._typing import (
42+
AxisInt,
43+
IndexKeyFunc,
44+
Level,
45+
NaPosition,
46+
Shape,
47+
SortKind,
48+
npt,
49+
)
5050

5151

5252
def get_indexer_indexer(

pyproject.toml

-5
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,6 @@ exclude = [
300300
"pandas/core/series.py" = ["TCH"]
301301
"pandas/core/resample.py" = ["TCH"]
302302
"pandas/core/nanops.py" = ["TCH"]
303-
"pandas/core/apply.py" = ["TCH"]
304-
"pandas/core/base.py" = ["TCH"]
305-
"pandas/core/algorithms.py" = ["TCH"]
306-
"pandas/core/ops/*" = ["TCH"]
307-
"pandas/core/sorting.py" = ["TCH"]
308303
"pandas/core/construction.py" = ["TCH"]
309304
"pandas/core/common.py" = ["TCH"]
310305
"pandas/core/missing.py" = ["TCH"]

0 commit comments

Comments
 (0)