Skip to content

Commit a4fec22

Browse files
authored
TYP: enable reportUnusedImport (pandas-dev#46937)
* TYP: enable reportUnusedImport * cannot instantiate Tick+BaseOffset * added new import to __all__ * remove references to now non-existing functions (found by pytest and reportUnsupportedDunderAll)
1 parent f74a186 commit a4fec22

29 files changed

+552
-52
lines changed

pandas/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa
21
from __future__ import annotations
32

43
__docformat__ = "restructuredtext"
@@ -20,7 +19,7 @@
2019
del _hard_dependencies, _dependency, _missing_dependencies
2120

2221
# numpy compat
23-
from pandas.compat import is_numpy_dev as _is_numpy_dev
22+
from pandas.compat import is_numpy_dev as _is_numpy_dev # pyright: ignore # noqa:F401
2423

2524
try:
2625
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
@@ -44,7 +43,7 @@
4443
)
4544

4645
# let init-time option registration happen
47-
import pandas.core.config_init
46+
import pandas.core.config_init # pyright: ignore # noqa:F401
4847

4948
from pandas.core.api import (
5049
# dtype
@@ -134,7 +133,8 @@
134133
qcut,
135134
)
136135

137-
from pandas import api, arrays, errors, io, plotting, testing, tseries
136+
from pandas import api, arrays, errors, io, plotting, tseries
137+
from pandas import testing # noqa:PDF015
138138
from pandas.util._print_versions import show_versions
139139

140140
from pandas.io.api import (

pandas/_config/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"options",
1717
]
1818
from pandas._config import config
19-
from pandas._config import dates # noqa:F401
19+
from pandas._config import dates # pyright: ignore # noqa:F401
2020
from pandas._config.config import (
2121
describe_option,
2222
get_option,

pandas/_testing/__init__.py

+132-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import numpy as np
2121

22-
from pandas._config.localization import ( # noqa:F401
22+
from pandas._config.localization import (
2323
can_set_locale,
2424
get_locales,
2525
set_locale,
@@ -49,24 +49,24 @@
4949
Series,
5050
bdate_range,
5151
)
52-
from pandas._testing._io import ( # noqa:F401
52+
from pandas._testing._io import (
5353
close,
5454
network,
5555
round_trip_localpath,
5656
round_trip_pathlib,
5757
round_trip_pickle,
5858
write_to_compressed,
5959
)
60-
from pandas._testing._random import ( # noqa:F401
60+
from pandas._testing._random import (
6161
randbool,
6262
rands,
6363
rands_array,
6464
)
65-
from pandas._testing._warnings import ( # noqa:F401
65+
from pandas._testing._warnings import (
6666
assert_produces_warning,
6767
maybe_produces_warning,
6868
)
69-
from pandas._testing.asserters import ( # noqa:F401
69+
from pandas._testing.asserters import (
7070
assert_almost_equal,
7171
assert_attr_equal,
7272
assert_categorical_equal,
@@ -91,11 +91,11 @@
9191
assert_timedelta_array_equal,
9292
raise_assert_detail,
9393
)
94-
from pandas._testing.compat import ( # noqa:F401
94+
from pandas._testing.compat import (
9595
get_dtype,
9696
get_obj,
9797
)
98-
from pandas._testing.contexts import ( # noqa:F401
98+
from pandas._testing.contexts import (
9999
RNGContext,
100100
decompress_file,
101101
ensure_clean,
@@ -1033,3 +1033,128 @@ def shares_memory(left, right) -> bool:
10331033
return shares_memory(arr, right)
10341034

10351035
raise NotImplementedError(type(left), type(right))
1036+
1037+
1038+
__all__ = [
1039+
"ALL_INT_EA_DTYPES",
1040+
"ALL_INT_NUMPY_DTYPES",
1041+
"ALL_NUMPY_DTYPES",
1042+
"ALL_REAL_NUMPY_DTYPES",
1043+
"all_timeseries_index_generator",
1044+
"assert_almost_equal",
1045+
"assert_attr_equal",
1046+
"assert_categorical_equal",
1047+
"assert_class_equal",
1048+
"assert_contains_all",
1049+
"assert_copy",
1050+
"assert_datetime_array_equal",
1051+
"assert_dict_equal",
1052+
"assert_equal",
1053+
"assert_extension_array_equal",
1054+
"assert_frame_equal",
1055+
"assert_index_equal",
1056+
"assert_indexing_slices_equivalent",
1057+
"assert_interval_array_equal",
1058+
"assert_is_sorted",
1059+
"assert_is_valid_plot_return_object",
1060+
"assert_metadata_equivalent",
1061+
"assert_numpy_array_equal",
1062+
"assert_period_array_equal",
1063+
"assert_produces_warning",
1064+
"assert_series_equal",
1065+
"assert_sp_array_equal",
1066+
"assert_timedelta_array_equal",
1067+
"at",
1068+
"BOOL_DTYPES",
1069+
"box_expected",
1070+
"BYTES_DTYPES",
1071+
"can_set_locale",
1072+
"close",
1073+
"COMPLEX_DTYPES",
1074+
"convert_rows_list_to_csv_str",
1075+
"DATETIME64_DTYPES",
1076+
"decompress_file",
1077+
"EMPTY_STRING_PATTERN",
1078+
"ENDIAN",
1079+
"ensure_clean",
1080+
"ensure_clean_dir",
1081+
"ensure_safe_environment_variables",
1082+
"equalContents",
1083+
"external_error_raised",
1084+
"FLOAT_EA_DTYPES",
1085+
"FLOAT_NUMPY_DTYPES",
1086+
"getCols",
1087+
"get_cython_table_params",
1088+
"get_dtype",
1089+
"getitem",
1090+
"get_locales",
1091+
"getMixedTypeDict",
1092+
"get_obj",
1093+
"get_op_from_name",
1094+
"getPeriodData",
1095+
"getSeriesData",
1096+
"getTimeSeriesData",
1097+
"iat",
1098+
"iloc",
1099+
"index_subclass_makers_generator",
1100+
"loc",
1101+
"makeBoolIndex",
1102+
"makeCategoricalIndex",
1103+
"makeCustomDataframe",
1104+
"makeCustomIndex",
1105+
"makeDataFrame",
1106+
"makeDateIndex",
1107+
"makeFloatIndex",
1108+
"makeFloatSeries",
1109+
"makeIntervalIndex",
1110+
"makeIntIndex",
1111+
"makeMissingDataframe",
1112+
"makeMixedDataFrame",
1113+
"makeMultiIndex",
1114+
"makeNumericIndex",
1115+
"makeObjectSeries",
1116+
"makePeriodFrame",
1117+
"makePeriodIndex",
1118+
"makePeriodSeries",
1119+
"make_rand_series",
1120+
"makeRangeIndex",
1121+
"makeStringIndex",
1122+
"makeStringSeries",
1123+
"makeTimeDataFrame",
1124+
"makeTimedeltaIndex",
1125+
"makeTimeSeries",
1126+
"makeUIntIndex",
1127+
"maybe_produces_warning",
1128+
"NARROW_NP_DTYPES",
1129+
"network",
1130+
"NP_NAT_OBJECTS",
1131+
"NULL_OBJECTS",
1132+
"OBJECT_DTYPES",
1133+
"raise_assert_detail",
1134+
"randbool",
1135+
"rands",
1136+
"reset_display_options",
1137+
"reset_testing_mode",
1138+
"RNGContext",
1139+
"round_trip_localpath",
1140+
"round_trip_pathlib",
1141+
"round_trip_pickle",
1142+
"setitem",
1143+
"set_locale",
1144+
"set_testing_mode",
1145+
"set_timezone",
1146+
"shares_memory",
1147+
"SIGNED_INT_EA_DTYPES",
1148+
"SIGNED_INT_NUMPY_DTYPES",
1149+
"STRING_DTYPES",
1150+
"SubclassedCategorical",
1151+
"SubclassedDataFrame",
1152+
"SubclassedSeries",
1153+
"TIMEDELTA64_DTYPES",
1154+
"to_array",
1155+
"UNSIGNED_INT_EA_DTYPES",
1156+
"UNSIGNED_INT_NUMPY_DTYPES",
1157+
"use_numexpr",
1158+
"with_csv_dialect",
1159+
"write_to_compressed",
1160+
]

pandas/api/__init__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
""" public toolkit API """
2-
from pandas.api import ( # noqa:F401
2+
from pandas.api import (
33
exchange,
44
extensions,
55
indexers,
66
types,
77
)
8+
9+
__all__ = [
10+
"exchange",
11+
"extensions",
12+
"indexers",
13+
"types",
14+
]

pandas/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ def spmatrix(request):
17341734
params=[
17351735
getattr(pd.offsets, o)
17361736
for o in pd.offsets.__all__
1737-
if issubclass(getattr(pd.offsets, o), pd.offsets.Tick)
1737+
if issubclass(getattr(pd.offsets, o), pd.offsets.Tick) and o != "Tick"
17381738
]
17391739
)
17401740
def tick_classes(request):

pandas/core/api.py

+62-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# flake8: noqa:F401
2-
31
from pandas._libs import (
42
NaT,
53
Period,
@@ -84,3 +82,65 @@
8482

8583
# DataFrame needs to be imported after NamedAgg to avoid a circular import
8684
from pandas.core.frame import DataFrame # isort:skip
85+
86+
__all__ = [
87+
"array",
88+
"bdate_range",
89+
"BooleanDtype",
90+
"Categorical",
91+
"CategoricalDtype",
92+
"CategoricalIndex",
93+
"DataFrame",
94+
"DateOffset",
95+
"date_range",
96+
"DatetimeIndex",
97+
"DatetimeTZDtype",
98+
"factorize",
99+
"Flags",
100+
"Float32Dtype",
101+
"Float64Dtype",
102+
"Float64Index",
103+
"Grouper",
104+
"Index",
105+
"IndexSlice",
106+
"Int16Dtype",
107+
"Int32Dtype",
108+
"Int64Dtype",
109+
"Int64Index",
110+
"Int8Dtype",
111+
"Interval",
112+
"IntervalDtype",
113+
"IntervalIndex",
114+
"interval_range",
115+
"isna",
116+
"isnull",
117+
"MultiIndex",
118+
"NA",
119+
"NamedAgg",
120+
"NaT",
121+
"notna",
122+
"notnull",
123+
"NumericIndex",
124+
"Period",
125+
"PeriodDtype",
126+
"PeriodIndex",
127+
"period_range",
128+
"RangeIndex",
129+
"Series",
130+
"set_eng_float_format",
131+
"StringDtype",
132+
"Timedelta",
133+
"TimedeltaIndex",
134+
"timedelta_range",
135+
"Timestamp",
136+
"to_datetime",
137+
"to_numeric",
138+
"to_timedelta",
139+
"UInt16Dtype",
140+
"UInt32Dtype",
141+
"UInt64Dtype",
142+
"UInt64Index",
143+
"UInt8Dtype",
144+
"unique",
145+
"value_counts",
146+
]

pandas/core/arrays/arrow/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# flake8: noqa: F401
2-
31
from pandas.core.arrays.arrow.array import ArrowExtensionArray
2+
3+
__all__ = ["ArrowExtensionArray"]

pandas/core/arrays/sparse/__init__.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# flake8: noqa: F401
2-
31
from pandas.core.arrays.sparse.accessor import (
42
SparseAccessor,
53
SparseFrameAccessor,
@@ -11,3 +9,13 @@
119
make_sparse_index,
1210
)
1311
from pandas.core.arrays.sparse.dtype import SparseDtype
12+
13+
__all__ = [
14+
"BlockIndex",
15+
"IntIndex",
16+
"make_sparse_index",
17+
"SparseAccessor",
18+
"SparseArray",
19+
"SparseDtype",
20+
"SparseFrameAccessor",
21+
]

pandas/core/dtypes/api.py

+44-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# flake8: noqa:F401
2-
31
from pandas.core.dtypes.common import (
42
is_array_like,
53
is_bool,
@@ -43,3 +41,47 @@
4341
is_unsigned_integer_dtype,
4442
pandas_dtype,
4543
)
44+
45+
__all__ = [
46+
"is_array_like",
47+
"is_bool",
48+
"is_bool_dtype",
49+
"is_categorical",
50+
"is_categorical_dtype",
51+
"is_complex",
52+
"is_complex_dtype",
53+
"is_datetime64_any_dtype",
54+
"is_datetime64_dtype",
55+
"is_datetime64_ns_dtype",
56+
"is_datetime64tz_dtype",
57+
"is_dict_like",
58+
"is_dtype_equal",
59+
"is_extension_array_dtype",
60+
"is_extension_type",
61+
"is_file_like",
62+
"is_float",
63+
"is_float_dtype",
64+
"is_hashable",
65+
"is_int64_dtype",
66+
"is_integer",
67+
"is_integer_dtype",
68+
"is_interval",
69+
"is_interval_dtype",
70+
"is_iterator",
71+
"is_list_like",
72+
"is_named_tuple",
73+
"is_number",
74+
"is_numeric_dtype",
75+
"is_object_dtype",
76+
"is_period_dtype",
77+
"is_re",
78+
"is_re_compilable",
79+
"is_scalar",
80+
"is_signed_integer_dtype",
81+
"is_sparse",
82+
"is_string_dtype",
83+
"is_timedelta64_dtype",
84+
"is_timedelta64_ns_dtype",
85+
"is_unsigned_integer_dtype",
86+
"pandas_dtype",
87+
]

0 commit comments

Comments
 (0)