File tree 28 files changed +109
-45
lines changed
28 files changed +109
-45
lines changed Original file line number Diff line number Diff line change 77
77
78
78
import pandas .core .algorithms as algos
79
79
from pandas .core .arrays import datetimelike as dtl
80
- from pandas .core .arrays .base import ExtensionArray
81
80
import pandas .core .common as com
82
81
83
82
if TYPE_CHECKING :
91
90
DatetimeArray ,
92
91
TimedeltaArray ,
93
92
)
93
+ from pandas .core .arrays .base import ExtensionArray
94
+
94
95
95
96
BaseOffsetT = TypeVar ("BaseOffsetT" , bound = BaseOffset )
96
97
Original file line number Diff line number Diff line change 4
4
from __future__ import annotations
5
5
6
6
import abc
7
+ from typing import TYPE_CHECKING
7
8
8
9
from pandas .errors import NumExprClobberingError
9
10
10
11
from pandas .core .computation .align import (
11
12
align_terms ,
12
13
reconstruct_object ,
13
14
)
14
- from pandas .core .computation .expr import Expr
15
15
from pandas .core .computation .ops import (
16
16
MATHOPS ,
17
17
REDUCTIONS ,
18
18
)
19
19
20
20
import pandas .io .formats .printing as printing
21
21
22
+ if TYPE_CHECKING :
23
+ from pandas .core .computation .expr import Expr
24
+
22
25
_ne_builtins = frozenset (MATHOPS + REDUCTIONS )
23
26
24
27
Original file line number Diff line number Diff line change 4
4
from __future__ import annotations
5
5
6
6
import tokenize
7
+ from typing import TYPE_CHECKING
7
8
import warnings
8
9
9
10
from pandas ._libs .lib import no_default
15
16
PARSERS ,
16
17
Expr ,
17
18
)
18
- from pandas .core .computation .ops import BinOp
19
19
from pandas .core .computation .parsing import tokenize_string
20
20
from pandas .core .computation .scope import ensure_scope
21
21
22
22
from pandas .io .formats .printing import pprint_thing
23
23
24
+ if TYPE_CHECKING :
25
+ from pandas .core .computation .ops import BinOp
26
+
24
27
25
28
def _check_engine (engine : str | None ) -> str :
26
29
"""
Original file line number Diff line number Diff line change 3
3
4
4
import ast
5
5
from functools import partial
6
- from typing import Any
6
+ from typing import (
7
+ TYPE_CHECKING ,
8
+ Any ,
9
+ )
7
10
8
11
import numpy as np
9
12
12
15
Timestamp ,
13
16
)
14
17
from pandas ._typing import npt
15
- from pandas .compat .chainmap import DeepChainMap
16
18
from pandas .errors import UndefinedVariableError
17
19
18
20
from pandas .core .dtypes .common import is_list_like
34
36
pprint_thing_encoded ,
35
37
)
36
38
39
+ if TYPE_CHECKING :
40
+ from pandas .compat .chainmap import DeepChainMap
41
+
37
42
38
43
class PyTablesScope (_scope .Scope ):
39
44
__slots__ = ("queryables" ,)
Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
+ from typing import TYPE_CHECKING
4
+
3
5
import numpy as np
4
6
5
7
from pandas .core .algorithms import unique1d
8
10
CategoricalDtype ,
9
11
recode_for_categories ,
10
12
)
11
- from pandas .core .indexes .api import CategoricalIndex
13
+
14
+ if TYPE_CHECKING :
15
+ from pandas .core .indexes .api import CategoricalIndex
12
16
13
17
14
18
def recode_for_groupby (
Original file line number Diff line number Diff line change 11
11
from functools import partial
12
12
from textwrap import dedent
13
13
from typing import (
14
+ TYPE_CHECKING ,
14
15
Any ,
15
16
Callable ,
16
17
Hashable ,
72
73
import pandas .core .common as com
73
74
from pandas .core .construction import create_series_with_explicit_dtype
74
75
from pandas .core .frame import DataFrame
75
- from pandas .core .generic import NDFrame
76
76
from pandas .core .groupby import base
77
77
from pandas .core .groupby .groupby import (
78
78
GroupBy ,
93
93
94
94
from pandas .plotting import boxplot_frame_groupby
95
95
96
+ if TYPE_CHECKING :
97
+ from pandas .core .generic import NDFrame
98
+
96
99
# TODO(typing) the return value on this callable should be any *scalar*.
97
100
AggScalar = Union [str , Callable [..., Any ]]
98
101
# TODO: validate types on ScalarResult and move to _typing
Original file line number Diff line number Diff line change 10
10
import collections
11
11
import functools
12
12
from typing import (
13
+ TYPE_CHECKING ,
13
14
Callable ,
14
15
Generic ,
15
16
Hashable ,
77
78
)
78
79
from pandas .core .arrays .string_ import StringDtype
79
80
from pandas .core .frame import DataFrame
80
- from pandas .core .generic import NDFrame
81
81
from pandas .core .groupby import grouper
82
82
from pandas .core .indexes .api import (
83
83
CategoricalIndex ,
95
95
get_indexer_dict ,
96
96
)
97
97
98
+ if TYPE_CHECKING :
99
+ from pandas .core .generic import NDFrame
100
+
98
101
99
102
class WrappedCythonOp :
100
103
"""
Original file line number Diff line number Diff line change 4
4
from __future__ import annotations
5
5
6
6
from typing import (
7
+ TYPE_CHECKING ,
7
8
Callable ,
8
9
TypeVar ,
9
10
)
21
22
22
23
from pandas .core .dtypes .generic import ABCDataFrame
23
24
24
- from pandas .core .arrays import IntervalArray
25
- from pandas .core .arrays ._mixins import NDArrayBackedExtensionArray
26
25
from pandas .core .indexes .base import Index
27
26
27
+ if TYPE_CHECKING :
28
+ from pandas .core .arrays import IntervalArray
29
+ from pandas .core .arrays ._mixins import NDArrayBackedExtensionArray
30
+
28
31
_T = TypeVar ("_T" , bound = "NDArrayBackedExtensionIndex" )
29
32
_ExtensionIndexT = TypeVar ("_ExtensionIndexT" , bound = "ExtensionIndex" )
30
33
Original file line number Diff line number Diff line change 3
3
from collections import abc
4
4
from typing import TYPE_CHECKING
5
5
6
- import pandas as pd
7
6
from pandas .core .interchange .column import PandasColumn
8
7
from pandas .core .interchange .dataframe_protocol import DataFrame as DataFrameXchg
9
8
10
9
if TYPE_CHECKING :
10
+ import pandas as pd
11
11
from pandas import Index
12
12
13
13
Original file line number Diff line number Diff line change 98
98
PeriodArray ,
99
99
TimedeltaArray ,
100
100
)
101
- from pandas .core .arrays ._mixins import NDArrayBackedExtensionArray
102
101
from pandas .core .arrays .sparse import SparseDtype
103
102
from pandas .core .base import PandasObject
104
103
import pandas .core .common as com
115
114
Float64Index ,
116
115
Index ,
117
116
)
117
+ from pandas .core .arrays ._mixins import NDArrayBackedExtensionArray
118
118
119
119
# comparison is faster than is_object_dtype
120
120
_dtype_obj = np .dtype ("object" )
Original file line number Diff line number Diff line change 68
68
)
69
69
from pandas .core .groupby .grouper import Grouper
70
70
from pandas .core .groupby .ops import BinGrouper
71
- from pandas .core .indexes .api import Index
72
71
from pandas .core .indexes .datetimes import (
73
72
DatetimeIndex ,
74
73
date_range ,
96
95
if TYPE_CHECKING :
97
96
from pandas import (
98
97
DataFrame ,
98
+ Index ,
99
99
Series ,
100
100
)
101
101
Original file line number Diff line number Diff line change 73
73
MultiIndex ,
74
74
Series ,
75
75
)
76
- from pandas .core import groupby
77
76
import pandas .core .algorithms as algos
78
77
from pandas .core .arrays import ExtensionArray
79
78
from pandas .core .arrays ._mixins import NDArrayBackedExtensionArray
85
84
86
85
if TYPE_CHECKING :
87
86
from pandas import DataFrame
87
+ from pandas .core import groupby
88
88
from pandas .core .arrays import DatetimeArray
89
89
90
90
Original file line number Diff line number Diff line change 30
30
Index ,
31
31
MultiIndex ,
32
32
)
33
- from pandas .core .indexes .frozen import FrozenList
34
33
from pandas .core .series import Series
35
34
from pandas .core .sorting import (
36
35
compress_group_index ,
42
41
43
42
if TYPE_CHECKING :
44
43
from pandas .core .arrays import ExtensionArray
44
+ from pandas .core .indexes .frozen import FrozenList
45
45
46
46
47
47
class _Unstacker :
Original file line number Diff line number Diff line change 3
3
from collections import defaultdict
4
4
import datetime
5
5
from typing import (
6
+ TYPE_CHECKING ,
6
7
Any ,
7
8
DefaultDict ,
8
9
Tuple ,
21
22
combine_kwargs ,
22
23
validate_freeze_panes ,
23
24
)
24
- from pandas .io .formats .excel import ExcelCell
25
+
26
+ if TYPE_CHECKING :
27
+ from pandas .io .formats .excel import ExcelCell
25
28
26
29
27
30
class ODSWriter (ExcelWriter ):
Original file line number Diff line number Diff line change 21
21
WriteBuffer ,
22
22
)
23
23
24
- from pandas .core .indexes .api import Index
25
-
26
24
from pandas .io .formats import format as fmt
27
25
from pandas .io .formats .printing import pprint_thing
28
26
29
27
if TYPE_CHECKING :
30
- from pandas . core . frame import (
28
+ from pandas import (
31
29
DataFrame ,
30
+ Index ,
32
31
Series ,
33
32
)
34
33
Original file line number Diff line number Diff line change 8
8
abstractmethod ,
9
9
)
10
10
from typing import (
11
+ TYPE_CHECKING ,
11
12
Iterator ,
12
13
Sequence ,
13
14
)
16
17
17
18
from pandas .core .dtypes .generic import ABCMultiIndex
18
19
19
- from pandas .io .formats .format import DataFrameFormatter
20
+ if TYPE_CHECKING :
21
+ from pandas .io .formats .format import DataFrameFormatter
20
22
21
23
22
24
def _split_into_full_short_caption (
Original file line number Diff line number Diff line change 4
4
from __future__ import annotations
5
5
6
6
from shutil import get_terminal_size
7
- from typing import Iterable
7
+ from typing import (
8
+ TYPE_CHECKING ,
9
+ Iterable ,
10
+ )
8
11
9
12
import numpy as np
10
13
11
- from pandas .io .formats .format import DataFrameFormatter
12
14
from pandas .io .formats .printing import pprint_thing
13
15
16
+ if TYPE_CHECKING :
17
+ from pandas .io .formats .format import DataFrameFormatter
18
+
14
19
15
20
class StringFormatter :
16
21
"""Formatter for string representation of a dataframe."""
Original file line number Diff line number Diff line change 5
5
6
6
import codecs
7
7
import io
8
- from typing import Any
8
+ from typing import (
9
+ TYPE_CHECKING ,
10
+ Any ,
11
+ )
9
12
10
13
from pandas ._typing import (
11
14
CompressionOptions ,
20
23
from pandas .core .dtypes .common import is_list_like
21
24
from pandas .core .dtypes .missing import isna
22
25
23
- from pandas .core .frame import DataFrame
24
26
from pandas .core .shared_docs import _shared_docs
25
27
26
28
from pandas .io .common import get_handle
29
31
preprocess_data ,
30
32
)
31
33
34
+ if TYPE_CHECKING :
35
+ from pandas import DataFrame
36
+
32
37
33
38
@doc (
34
39
storage_options = _shared_docs ["storage_options" ],
Original file line number Diff line number Diff line change 10
10
import numbers
11
11
import re
12
12
from typing import (
13
+ TYPE_CHECKING ,
13
14
Iterable ,
14
15
Pattern ,
15
16
Sequence ,
30
31
from pandas .core .dtypes .common import is_list_like
31
32
32
33
from pandas .core .construction import create_series_with_explicit_dtype
33
- from pandas .core .frame import DataFrame
34
34
35
35
from pandas .io .common import (
36
36
file_exists ,
43
43
from pandas .io .formats .printing import pprint_thing
44
44
from pandas .io .parsers import TextParser
45
45
46
+ if TYPE_CHECKING :
47
+ from pandas import DataFrame
48
+
46
49
_IMPORTS = False
47
50
_HAS_BS4 = False
48
51
_HAS_LXML = False
You can’t perform that action at this time.
0 commit comments