Skip to content

Commit 7ad46b9

Browse files
author
MomIsBestFriend
committed
Moved ABCSparse array to bigger scope, for mypy
1 parent ccaf80c commit 7ad46b9

File tree

1 file changed

+101
-116
lines changed

1 file changed

+101
-116
lines changed

pandas/__init__.py

+101-116
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
)
1919
del hard_dependencies, dependency, missing_dependencies
2020

21+
from pandas._config import (
22+
describe_option,
23+
get_option,
24+
option_context,
25+
options,
26+
reset_option,
27+
set_option,
28+
)
29+
2130
# numpy compat
2231
from pandas.compat.numpy import (
2332
_np_version_under1p14,
@@ -26,160 +35,137 @@
2635
_np_version_under1p17,
2736
_np_version_under1p18,
2837
)
38+
from pandas.util._print_versions import show_versions
39+
from pandas.util._tester import test
2940

30-
try:
31-
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
32-
except ImportError as e: # pragma: no cover
33-
# hack but overkill to use re
34-
module = str(e).replace("cannot import name ", "")
35-
raise ImportError(
36-
f"C extension: {module} not built. If you want to import "
37-
"pandas from the source directory, you may need to run "
38-
"'python setup.py build_ext --inplace --force' to build the C extensions first."
39-
)
40-
41-
from pandas._config import (
42-
get_option,
43-
set_option,
44-
reset_option,
45-
describe_option,
46-
option_context,
47-
options,
48-
)
41+
from pandas.core.dtypes.generic import ABCSparseArray
4942

5043
# let init-time option registration happen
44+
import pandas.api
45+
import pandas.arrays
46+
from pandas.core.arrays.sparse import SparseDtype
47+
from pandas.core.computation.api import eval
5148
import pandas.core.config_init
49+
from pandas.core.reshape.api import (
50+
concat,
51+
crosstab,
52+
cut,
53+
get_dummies,
54+
lreshape,
55+
melt,
56+
merge,
57+
merge_asof,
58+
merge_ordered,
59+
pivot,
60+
pivot_table,
61+
qcut,
62+
wide_to_long,
63+
)
64+
import pandas.testing
5265

53-
from pandas.core.api import (
54-
# dtype
66+
from pandas.io.json import _json_normalize as json_normalize
67+
from pandas.tseries import offsets
68+
from pandas.tseries.api import infer_freq
69+
70+
# use the closest tagged version if possible
71+
from ._version import get_versions
72+
73+
from pandas.core.api import ( # dtype; missing; indexes; tseries; conversion; misc
74+
NA,
75+
BooleanDtype,
76+
Categorical,
77+
CategoricalDtype,
78+
CategoricalIndex,
79+
DataFrame,
80+
DateOffset,
81+
DatetimeIndex,
82+
DatetimeTZDtype,
83+
Float64Index,
84+
Grouper,
85+
Index,
86+
IndexSlice,
5587
Int8Dtype,
5688
Int16Dtype,
5789
Int32Dtype,
5890
Int64Dtype,
91+
Int64Index,
92+
Interval,
93+
IntervalDtype,
94+
IntervalIndex,
95+
MultiIndex,
96+
NamedAgg,
97+
NaT,
98+
Period,
99+
PeriodDtype,
100+
PeriodIndex,
101+
RangeIndex,
102+
Series,
103+
StringDtype,
104+
Timedelta,
105+
TimedeltaIndex,
106+
Timestamp,
59107
UInt8Dtype,
60108
UInt16Dtype,
61109
UInt32Dtype,
62110
UInt64Dtype,
63-
CategoricalDtype,
64-
PeriodDtype,
65-
IntervalDtype,
66-
DatetimeTZDtype,
67-
StringDtype,
68-
BooleanDtype,
69-
# missing
70-
NA,
111+
UInt64Index,
112+
array,
113+
bdate_range,
114+
date_range,
115+
factorize,
116+
interval_range,
71117
isna,
72118
isnull,
73119
notna,
74120
notnull,
75-
# indexes
76-
Index,
77-
CategoricalIndex,
78-
Int64Index,
79-
UInt64Index,
80-
RangeIndex,
81-
Float64Index,
82-
MultiIndex,
83-
IntervalIndex,
84-
TimedeltaIndex,
85-
DatetimeIndex,
86-
PeriodIndex,
87-
IndexSlice,
88-
# tseries
89-
NaT,
90-
Period,
91121
period_range,
92-
Timedelta,
122+
set_eng_float_format,
93123
timedelta_range,
94-
Timestamp,
95-
date_range,
96-
bdate_range,
97-
Interval,
98-
interval_range,
99-
DateOffset,
100-
# conversion
101-
to_numeric,
102124
to_datetime,
125+
to_numeric,
103126
to_timedelta,
104-
# misc
105-
Grouper,
106-
factorize,
107127
unique,
108128
value_counts,
109-
NamedAgg,
110-
array,
111-
Categorical,
112-
set_eng_float_format,
113-
Series,
114-
DataFrame,
115129
)
116130

117-
from pandas.core.arrays.sparse import SparseDtype
118-
119-
from pandas.tseries.api import infer_freq
120-
from pandas.tseries import offsets
121-
122-
from pandas.core.computation.api import eval
123-
124-
from pandas.core.reshape.api import (
125-
concat,
126-
lreshape,
127-
melt,
128-
wide_to_long,
129-
merge,
130-
merge_asof,
131-
merge_ordered,
132-
crosstab,
133-
pivot,
134-
pivot_table,
135-
get_dummies,
136-
cut,
137-
qcut,
138-
)
139-
140-
import pandas.api
141-
from pandas.util._print_versions import show_versions
142-
143-
from pandas.io.api import (
144-
# excel
131+
from pandas.io.api import ( # excel; parsers; pickle; pytables; sql; misc
145132
ExcelFile,
146133
ExcelWriter,
147-
read_excel,
148-
# parsers
149-
read_csv,
150-
read_fwf,
151-
read_table,
152-
# pickle
153-
read_pickle,
154-
to_pickle,
155-
# pytables
156134
HDFStore,
157-
read_hdf,
158-
# sql
159-
read_sql,
160-
read_sql_query,
161-
read_sql_table,
162-
# misc
163135
read_clipboard,
164-
read_parquet,
165-
read_orc,
136+
read_csv,
137+
read_excel,
166138
read_feather,
139+
read_fwf,
167140
read_gbq,
141+
read_hdf,
168142
read_html,
169143
read_json,
170-
read_stata,
144+
read_orc,
145+
read_parquet,
146+
read_pickle,
171147
read_sas,
172148
read_spss,
149+
read_sql,
150+
read_sql_query,
151+
read_sql_table,
152+
read_stata,
153+
read_table,
154+
to_pickle,
173155
)
174156

175-
from pandas.io.json import _json_normalize as json_normalize
176157

177-
from pandas.util._tester import test
178-
import pandas.testing
179-
import pandas.arrays
158+
try:
159+
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
160+
except ImportError as e: # pragma: no cover
161+
# hack but overkill to use re
162+
module = str(e).replace("cannot import name ", "")
163+
raise ImportError(
164+
f"C extension: {module} not built. If you want to import "
165+
"pandas from the source directory, you may need to run "
166+
"'python setup.py build_ext --inplace --force' to build the C extensions first."
167+
)
180168

181-
# use the closest tagged version if possible
182-
from ._version import get_versions
183169

184170
v = get_versions()
185171
__version__ = v.get("closest-tag", v["version"])
@@ -334,7 +320,6 @@ def __new__(cls, *args, **kwargs):
334320
class __SparseArray(type):
335321

336322
from pandas.core.arrays.sparse import SparseArray as sa
337-
from pandas.core.dtypes.generic import ABCSparseArray
338323

339324
SparseArray = sa
340325

0 commit comments

Comments
 (0)