Skip to content

Commit edf1ba1

Browse files
authored
STYLE: Enable ruff TCH on some files (#51812)
* STYLE: enable ruff TCH * Fix circular import
1 parent 178e504 commit edf1ba1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+388
-285
lines changed

pandas/core/reshape/concat.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919

2020
from pandas._config import using_copy_on_write
2121

22-
from pandas._typing import (
23-
Axis,
24-
AxisInt,
25-
HashableT,
26-
)
2722
from pandas.util._decorators import cache_readonly
2823

2924
from pandas.core.dtypes.concat import concat_compat
@@ -51,6 +46,12 @@
5146
from pandas.core.internals import concatenate_managers
5247

5348
if TYPE_CHECKING:
49+
from pandas._typing import (
50+
Axis,
51+
AxisInt,
52+
HashableT,
53+
)
54+
5455
from pandas import (
5556
DataFrame,
5657
Series,

pandas/core/reshape/encoding.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from collections import defaultdict
44
import itertools
55
from typing import (
6+
TYPE_CHECKING,
67
Hashable,
78
Iterable,
89
)
910

1011
import numpy as np
1112

1213
from pandas._libs.sparse import IntIndex
13-
from pandas._typing import NpDtype
1414

1515
from pandas.core.dtypes.common import (
1616
is_integer_dtype,
@@ -28,6 +28,9 @@
2828
)
2929
from pandas.core.series import Series
3030

31+
if TYPE_CHECKING:
32+
from pandas._typing import NpDtype
33+
3134

3235
def get_dummies(
3336
data,

pandas/core/reshape/pivot.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
import numpy as np
1212

1313
from pandas._libs import lib
14-
from pandas._typing import (
15-
AggFuncType,
16-
AggFuncTypeBase,
17-
AggFuncTypeDict,
18-
IndexLabel,
19-
)
2014
from pandas.util._decorators import (
2115
Appender,
2216
Substitution,
@@ -48,6 +42,13 @@
4842
from pandas.core.series import Series
4943

5044
if TYPE_CHECKING:
45+
from pandas._typing import (
46+
AggFuncType,
47+
AggFuncTypeBase,
48+
AggFuncTypeDict,
49+
IndexLabel,
50+
)
51+
5152
from pandas import DataFrame
5253

5354

pandas/core/reshape/reshape.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import numpy as np
1111

1212
import pandas._libs.reshape as libreshape
13-
from pandas._typing import npt
1413
from pandas.errors import PerformanceWarning
1514
from pandas.util._decorators import cache_readonly
1615
from pandas.util._exceptions import find_stack_level
@@ -44,6 +43,8 @@
4443
)
4544

4645
if TYPE_CHECKING:
46+
from pandas._typing import npt
47+
4748
from pandas.core.arrays import ExtensionArray
4849
from pandas.core.indexes.frozen import FrozenList
4950

pandas/core/reshape/tile.py

Lines changed: 4 additions & 1 deletion
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
Literal,
@@ -16,7 +17,6 @@
1617
Timestamp,
1718
)
1819
from pandas._libs.lib import infer_dtype
19-
from pandas._typing import IntervalLeftRight
2020

2121
from pandas.core.dtypes.common import (
2222
DT64NS_DTYPE,
@@ -46,6 +46,9 @@
4646
from pandas.core import nanops
4747
import pandas.core.algorithms as algos
4848

49+
if TYPE_CHECKING:
50+
from pandas._typing import IntervalLeftRight
51+
4952

5053
def cut(
5154
x,

pandas/core/reshape/util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from __future__ import annotations
22

3-
import numpy as np
3+
from typing import TYPE_CHECKING
44

5-
from pandas._typing import NumpyIndexT
5+
import numpy as np
66

77
from pandas.core.dtypes.common import is_list_like
88

9+
if TYPE_CHECKING:
10+
from pandas._typing import NumpyIndexT
11+
912

1013
def cartesian_product(X) -> list[np.ndarray]:
1114
"""

pandas/core/strings/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import abc
4-
import re
54
from typing import (
65
TYPE_CHECKING,
76
Callable,
@@ -10,9 +9,11 @@
109

1110
import numpy as np
1211

13-
from pandas._typing import Scalar
14-
1512
if TYPE_CHECKING:
13+
import re
14+
15+
from pandas._typing import Scalar
16+
1617
from pandas import Series
1718

1819

pandas/core/strings/object_array.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@
1616
from pandas._libs import lib
1717
import pandas._libs.missing as libmissing
1818
import pandas._libs.ops as libops
19-
from pandas._typing import (
20-
NpDtype,
21-
Scalar,
22-
)
2319

2420
from pandas.core.dtypes.common import is_scalar
2521
from pandas.core.dtypes.missing import isna
2622

2723
from pandas.core.strings.base import BaseStringArrayMethods
2824

2925
if TYPE_CHECKING:
26+
from pandas._typing import (
27+
NpDtype,
28+
Scalar,
29+
)
30+
3031
from pandas import Series
3132

3233

pandas/core/tools/numeric.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from __future__ import annotations
22

3-
from typing import Literal
3+
from typing import (
4+
TYPE_CHECKING,
5+
Literal,
6+
)
47

58
import numpy as np
69

@@ -10,10 +13,6 @@
1013
)
1114

1215
from pandas._libs import lib
13-
from pandas._typing import (
14-
DateTimeErrorChoices,
15-
npt,
16-
)
1716

1817
from pandas.core.dtypes.cast import maybe_downcast_numeric
1918
from pandas.core.dtypes.common import (
@@ -36,6 +35,12 @@
3635
import pandas as pd
3736
from pandas.core.arrays import BaseMaskedArray
3837

38+
if TYPE_CHECKING:
39+
from pandas._typing import (
40+
DateTimeErrorChoices,
41+
npt,
42+
)
43+
3944

4045
def to_numeric(
4146
arg,

pandas/core/tools/timedeltas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
from __future__ import annotations
55

6-
from datetime import timedelta
76
from typing import (
87
TYPE_CHECKING,
98
overload,
@@ -30,6 +29,8 @@
3029
from pandas.core.arrays.timedeltas import sequence_to_td64ns
3130

3231
if TYPE_CHECKING:
32+
from datetime import timedelta
33+
3334
from pandas._libs.tslibs.timedeltas import UnitChoices
3435
from pandas._typing import (
3536
ArrayLike,

0 commit comments

Comments
 (0)