Skip to content

Commit 4ab1c76

Browse files
STYLE: Enable ruff TCH on some files (#51781)
STYLE enable ruff TCH Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent 3b94ec5 commit 4ab1c76

16 files changed

+162
-141
lines changed

pandas/core/array_algos/masked_accumulations.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55

66
from __future__ import annotations
77

8-
from typing import Callable
8+
from typing import (
9+
TYPE_CHECKING,
10+
Callable,
11+
)
912

1013
import numpy as np
1114

12-
from pandas._typing import npt
13-
1415
from pandas.core.dtypes.common import (
1516
is_bool_dtype,
1617
is_float_dtype,
1718
is_integer_dtype,
1819
)
1920

21+
if TYPE_CHECKING:
22+
from pandas._typing import npt
23+
2024

2125
def _cum_func(
2226
func: Callable,

pandas/core/array_algos/masked_reductions.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@
44
"""
55
from __future__ import annotations
66

7-
from typing import Callable
7+
from typing import (
8+
TYPE_CHECKING,
9+
Callable,
10+
)
811

912
import numpy as np
1013

1114
from pandas._libs import missing as libmissing
12-
from pandas._typing import (
13-
AxisInt,
14-
npt,
15-
)
1615

1716
from pandas.core.nanops import check_below_min_count
1817

18+
if TYPE_CHECKING:
19+
from pandas._typing import (
20+
AxisInt,
21+
npt,
22+
)
23+
1924

2025
def _reductions(
2126
func: Callable,

pandas/core/array_algos/putmask.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
import numpy as np
1212

1313
from pandas._libs import lib
14-
from pandas._typing import (
15-
ArrayLike,
16-
npt,
17-
)
1814
from pandas.compat import np_version_under1p21
1915

2016
from pandas.core.dtypes.cast import infer_dtype_from
@@ -23,6 +19,11 @@
2319
from pandas.core.arrays import ExtensionArray
2420

2521
if TYPE_CHECKING:
22+
from pandas._typing import (
23+
ArrayLike,
24+
npt,
25+
)
26+
2627
from pandas import MultiIndex
2728

2829

pandas/core/array_algos/quantile.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
from __future__ import annotations
22

3+
from typing import TYPE_CHECKING
4+
35
import numpy as np
46

5-
from pandas._typing import (
6-
ArrayLike,
7-
Scalar,
8-
npt,
9-
)
107
from pandas.compat.numpy import np_percentile_argname
118

129
from pandas.core.dtypes.missing import (
1310
isna,
1411
na_value_for_dtype,
1512
)
1613

14+
if TYPE_CHECKING:
15+
from pandas._typing import (
16+
ArrayLike,
17+
Scalar,
18+
npt,
19+
)
20+
1721

1822
def quantile_compat(
1923
values: ArrayLike, qs: npt.NDArray[np.float64], interpolation: str

pandas/core/array_algos/replace.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@
66
import operator
77
import re
88
from typing import (
9+
TYPE_CHECKING,
910
Any,
1011
Pattern,
1112
)
1213

1314
import numpy as np
1415

15-
from pandas._typing import (
16-
ArrayLike,
17-
Scalar,
18-
npt,
19-
)
20-
2116
from pandas.core.dtypes.common import (
2217
is_re,
2318
is_re_compilable,
2419
is_scalar,
2520
)
2621
from pandas.core.dtypes.missing import isna
2722

23+
if TYPE_CHECKING:
24+
from pandas._typing import (
25+
ArrayLike,
26+
Scalar,
27+
npt,
28+
)
29+
2830

2931
def should_use_regex(regex: bool, to_replace: Any) -> bool:
3032
"""

pandas/core/array_algos/take.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
algos as libalgos,
1414
lib,
1515
)
16-
from pandas._typing import (
17-
ArrayLike,
18-
AxisInt,
19-
npt,
20-
)
2116

2217
from pandas.core.dtypes.cast import maybe_promote
2318
from pandas.core.dtypes.common import (
@@ -29,6 +24,12 @@
2924
from pandas.core.construction import ensure_wrapped_if_datetimelike
3025

3126
if TYPE_CHECKING:
27+
from pandas._typing import (
28+
ArrayLike,
29+
AxisInt,
30+
npt,
31+
)
32+
3233
from pandas.core.arrays._mixins import NDArrayBackedExtensionArray
3334
from pandas.core.arrays.base import ExtensionArray
3435

pandas/core/array_algos/transforms.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
from __future__ import annotations
66

7+
from typing import TYPE_CHECKING
8+
79
import numpy as np
810

9-
from pandas._typing import AxisInt
11+
if TYPE_CHECKING:
12+
from pandas._typing import AxisInt
1013

1114

1215
def shift(values: np.ndarray, periods: int, axis: AxisInt, fill_value) -> np.ndarray:

pandas/core/dtypes/astype.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515

1616
from pandas._libs import lib
1717
from pandas._libs.tslibs.timedeltas import array_to_timedelta64
18-
from pandas._typing import (
19-
ArrayLike,
20-
DtypeObj,
21-
IgnoreRaise,
22-
)
2318
from pandas.errors import IntCastingNaNError
2419

2520
from pandas.core.dtypes.common import (
@@ -37,8 +32,13 @@
3732
)
3833

3934
if TYPE_CHECKING:
40-
from pandas.core.arrays import ExtensionArray
35+
from pandas._typing import (
36+
ArrayLike,
37+
DtypeObj,
38+
IgnoreRaise,
39+
)
4140

41+
from pandas.core.arrays import ExtensionArray
4242

4343
_dtype_obj = np.dtype(object)
4444

pandas/core/dtypes/base.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515

1616
from pandas._libs import missing as libmissing
1717
from pandas._libs.hashtable import object_hash
18-
from pandas._typing import (
19-
DtypeObj,
20-
Shape,
21-
npt,
22-
type_t,
23-
)
2418
from pandas.errors import AbstractMethodError
2519

2620
from pandas.core.dtypes.generic import (
@@ -30,6 +24,13 @@
3024
)
3125

3226
if TYPE_CHECKING:
27+
from pandas._typing import (
28+
DtypeObj,
29+
Shape,
30+
npt,
31+
type_t,
32+
)
33+
3334
from pandas.core.arrays import ExtensionArray
3435

3536
# To parameterize on same ExtensionDtype

pandas/core/dtypes/cast.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@
3636
is_supported_unit,
3737
)
3838
from pandas._libs.tslibs.timedeltas import array_to_timedelta64
39-
from pandas._typing import (
40-
ArrayLike,
41-
Dtype,
42-
DtypeObj,
43-
NumpyIndexT,
44-
Scalar,
45-
npt,
46-
)
4739
from pandas.errors import (
4840
IntCastingNaNError,
4941
LossySetitemError,
@@ -100,6 +92,15 @@
10092
)
10193

10294
if TYPE_CHECKING:
95+
from pandas._typing import (
96+
ArrayLike,
97+
Dtype,
98+
DtypeObj,
99+
NumpyIndexT,
100+
Scalar,
101+
npt,
102+
)
103+
103104
from pandas import Index
104105
from pandas.core.arrays import (
105106
Categorical,

pandas/core/dtypes/common.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import annotations
55

66
from typing import (
7+
TYPE_CHECKING,
78
Any,
89
Callable,
910
)
@@ -17,10 +18,6 @@
1718
lib,
1819
)
1920
from pandas._libs.tslibs import conversion
20-
from pandas._typing import (
21-
ArrayLike,
22-
DtypeObj,
23-
)
2421

2522
from pandas.core.dtypes.base import _registry as registry
2623
from pandas.core.dtypes.dtypes import (
@@ -54,6 +51,12 @@
5451
is_sequence,
5552
)
5653

54+
if TYPE_CHECKING:
55+
from pandas._typing import (
56+
ArrayLike,
57+
DtypeObj,
58+
)
59+
5760
DT64NS_DTYPE = conversion.DT64NS_DTYPE
5861
TD64NS_DTYPE = conversion.TD64NS_DTYPE
5962
INT64_DTYPE = np.dtype(np.int64)

pandas/core/dtypes/concat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import numpy as np
99

10-
from pandas._typing import AxisInt
11-
1210
from pandas.core.dtypes.astype import astype_array
1311
from pandas.core.dtypes.cast import (
1412
common_dtype_categorical_compat,
@@ -26,6 +24,8 @@
2624
)
2725

2826
if TYPE_CHECKING:
27+
from pandas._typing import AxisInt
28+
2929
from pandas.core.arrays import Categorical
3030

3131

pandas/core/dtypes/dtypes.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
PeriodDtypeBase,
3232
abbrev_to_npy_unit,
3333
)
34-
from pandas._typing import (
35-
Dtype,
36-
DtypeObj,
37-
Ordered,
38-
npt,
39-
type_t,
40-
)
4134

4235
from pandas.core.dtypes.base import (
4336
ExtensionDtype,
@@ -57,6 +50,14 @@
5750

5851
import pyarrow
5952

53+
from pandas._typing import (
54+
Dtype,
55+
DtypeObj,
56+
Ordered,
57+
npt,
58+
type_t,
59+
)
60+
6061
from pandas import (
6162
Categorical,
6263
Index,

0 commit comments

Comments
 (0)