Skip to content

Commit 3a27432

Browse files
committed
enable reportUnknownVariableType
1 parent 6a7c381 commit 3a27432

Some content is hidden

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

74 files changed

+885
-743
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ repos:
1818
hooks:
1919
- id: isort
2020
- repo: https://github.com/psf/black
21-
rev: 25.9.0
21+
rev: 25.11.0
2222
hooks:
2323
- id: black

pandas-stubs/__init__.pyi

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,20 @@ from pandas.core.api import (
6161
timedelta_range as timedelta_range,
6262
to_datetime as to_datetime,
6363
to_numeric as to_numeric,
64-
to_timedelta as to_timedelta,
6564
unique as unique,
66-
value_counts as value_counts,
65+
)
66+
from pandas.core.api import (
67+
to_timedelta as to_timedelta, # pyright: ignore[reportUnknownVariableType]
68+
)
69+
from pandas.core.api import (
70+
value_counts as value_counts, # pyright: ignore[reportUnknownVariableType]
6771
)
6872
from pandas.core.arrays.sparse import SparseDtype as SparseDtype
69-
from pandas.core.computation.api import eval as eval
73+
from pandas.core.computation.api import (
74+
eval as eval, # pyright: ignore[reportUnknownVariableType]
75+
)
7076
from pandas.core.reshape.api import (
7177
concat as concat,
72-
crosstab as crosstab,
73-
cut as cut,
7478
from_dummies as from_dummies,
7579
get_dummies as get_dummies,
7680
lreshape as lreshape,
@@ -79,10 +83,18 @@ from pandas.core.reshape.api import (
7983
merge_asof as merge_asof,
8084
merge_ordered as merge_ordered,
8185
pivot as pivot,
82-
pivot_table as pivot_table,
8386
qcut as qcut,
8487
wide_to_long as wide_to_long,
8588
)
89+
from pandas.core.reshape.api import (
90+
crosstab as crosstab, # pyright: ignore[reportUnknownVariableType]
91+
)
92+
from pandas.core.reshape.api import (
93+
cut as cut, # pyright: ignore[reportUnknownVariableType]
94+
)
95+
from pandas.core.reshape.api import (
96+
pivot_table as pivot_table, # pyright: ignore[reportUnknownVariableType]
97+
)
8698

8799
from pandas._config import (
88100
describe_option as describe_option,
@@ -99,27 +111,49 @@ from pandas.io.api import (
99111
ExcelFile as ExcelFile,
100112
ExcelWriter as ExcelWriter,
101113
HDFStore as HDFStore,
102-
read_clipboard as read_clipboard,
103-
read_csv as read_csv,
104-
read_excel as read_excel,
105114
read_feather as read_feather,
106115
read_fwf as read_fwf,
107116
read_hdf as read_hdf,
108-
read_html as read_html,
109117
read_json as read_json,
110-
read_orc as read_orc,
111-
read_parquet as read_parquet,
112118
read_pickle as read_pickle,
113119
read_sas as read_sas,
114120
read_spss as read_spss,
115-
read_sql as read_sql,
116-
read_sql_query as read_sql_query,
117121
read_sql_table as read_sql_table,
118122
read_stata as read_stata,
119-
read_table as read_table,
120-
read_xml as read_xml,
121123
)
122-
from pandas.io.json._normalize import json_normalize as json_normalize
124+
from pandas.io.api import (
125+
read_clipboard as read_clipboard, # pyright: ignore[reportUnknownVariableType]
126+
)
127+
from pandas.io.api import (
128+
read_csv as read_csv, # pyright: ignore[reportUnknownVariableType]
129+
)
130+
from pandas.io.api import (
131+
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
132+
)
133+
from pandas.io.api import (
134+
read_html as read_html, # pyright: ignore[reportUnknownVariableType]
135+
)
136+
from pandas.io.api import (
137+
read_orc as read_orc, # pyright: ignore[reportUnknownVariableType]
138+
)
139+
from pandas.io.api import (
140+
read_parquet as read_parquet, # pyright: ignore[reportUnknownVariableType]
141+
)
142+
from pandas.io.api import (
143+
read_sql as read_sql, # pyright: ignore[reportUnknownVariableType]
144+
)
145+
from pandas.io.api import (
146+
read_sql_query as read_sql_query, # pyright: ignore[reportUnknownVariableType]
147+
)
148+
from pandas.io.api import (
149+
read_table as read_table, # pyright: ignore[reportUnknownVariableType]
150+
)
151+
from pandas.io.api import (
152+
read_xml as read_xml, # pyright: ignore[reportUnknownVariableType]
153+
)
154+
from pandas.io.json._normalize import (
155+
json_normalize as json_normalize, # pyright: ignore[reportUnknownVariableType]
156+
)
123157
from pandas.tseries import offsets as offsets
124158
from pandas.tseries.api import infer_freq as infer_freq
125159

pandas-stubs/_typing.pyi

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ from typing import (
2222
SupportsIndex,
2323
TypeAlias,
2424
TypedDict,
25-
Union,
2625
overload,
2726
)
2827

@@ -596,18 +595,25 @@ IndexKeyFunc: TypeAlias = Callable[[Index], Index | AnyArrayLike] | None
596595

597596
# types of `func` kwarg for DataFrame.aggregate and Series.aggregate
598597
# More specific than what is in pandas
599-
# following Union is here to make it ty compliant https://github.com/astral-sh/ty/issues/591
600-
AggFuncTypeBase: TypeAlias = Union[Callable, str, np.ufunc] # noqa: UP007
598+
AggFuncTypeBase: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
599+
Callable | str | np.ufunc
600+
)
601601
AggFuncTypeDictSeries: TypeAlias = Mapping[HashableT, AggFuncTypeBase]
602602
AggFuncTypeDictFrame: TypeAlias = Mapping[
603603
HashableT, AggFuncTypeBase | list[AggFuncTypeBase]
604604
]
605-
AggFuncTypeSeriesToFrame: TypeAlias = list[AggFuncTypeBase] | AggFuncTypeDictSeries
606-
AggFuncTypeFrame: TypeAlias = (
605+
AggFuncTypeSeriesToFrame: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
606+
list[AggFuncTypeBase] | AggFuncTypeDictSeries
607+
)
608+
AggFuncTypeFrame: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
607609
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDictFrame
608610
)
609-
AggFuncTypeDict: TypeAlias = AggFuncTypeDictSeries | AggFuncTypeDictFrame
610-
AggFuncType: TypeAlias = AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDict
611+
AggFuncTypeDict: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
612+
AggFuncTypeDictSeries | AggFuncTypeDictFrame
613+
)
614+
AggFuncType: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
615+
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDict
616+
)
611617

612618
# Not used in stubs
613619
# AggObjType = Union[

pandas-stubs/core/api.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from pandas.core.algorithms import (
22
factorize as factorize,
33
unique as unique,
4-
value_counts as value_counts,
4+
)
5+
from pandas.core.algorithms import (
6+
value_counts as value_counts, # pyright: ignore[reportUnknownVariableType]
57
)
68
from pandas.core.arrays import Categorical as Categorical
79
from pandas.core.arrays.arrow.dtype import ArrowDtype as ArrowDtype
@@ -51,7 +53,9 @@ from pandas.core.indexing import IndexSlice as IndexSlice
5153
from pandas.core.series import Series as Series
5254
from pandas.core.tools.datetimes import to_datetime as to_datetime
5355
from pandas.core.tools.numeric import to_numeric as to_numeric
54-
from pandas.core.tools.timedeltas import to_timedelta as to_timedelta
56+
from pandas.core.tools.timedeltas import (
57+
to_timedelta as to_timedelta, # pyright: ignore[reportUnknownVariableType]
58+
)
5559

5660
from pandas._libs import (
5761
NaT as NaT,
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
from pandas.core.computation.eval import eval as eval
1+
from pandas.core.computation.eval import (
2+
eval as eval, # pyright: ignore[reportUnknownVariableType]
3+
)

pandas-stubs/core/frame.pyi

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ from pandas.core.indexing import (
5757
_LocIndexer,
5858
)
5959
from pandas.core.reshape.pivot import (
60-
_PivotAggFunc,
60+
_PivotAggFunc, # pyright: ignore[reportUnknownVariableType]
61+
)
62+
from pandas.core.reshape.pivot import (
6163
_PivotTableColumnsTypes,
6264
_PivotTableIndexTypes,
6365
_PivotTableValuesTypes,
@@ -81,12 +83,13 @@ from pandas._libs.lib import _NoDefaultDoNotUse
8183
from pandas._libs.missing import NAType
8284
from pandas._libs.tslibs import BaseOffset
8385
from pandas._libs.tslibs.nattype import NaTType
86+
from pandas._typing import (
87+
AggFuncTypeFrame, # pyright: ignore[reportUnknownVariableType]
88+
)
8489
from pandas._typing import (
8590
S2,
86-
AggFuncTypeBase,
8791
AggFuncTypeDictFrame,
8892
AggFuncTypeDictSeries,
89-
AggFuncTypeFrame,
9093
AlignJoin,
9194
AnyAll,
9295
AnyArrayLike,
@@ -171,6 +174,7 @@ from pandas._typing import (
171174
np_ndarray_float,
172175
np_ndarray_num,
173176
)
177+
from pandas._typing import AggFuncTypeBase # pyright: ignore[reportUnknownVariableType]
174178

175179
from pandas.io.formats.style import Styler
176180
from pandas.plotting import PlotAccessor
@@ -1527,7 +1531,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
15271531
axis: Axis = 0,
15281532
**kwargs: Any,
15291533
) -> Self: ...
1530-
agg = aggregate
1534+
agg = aggregate # pyright: ignore[reportUnknownVariableType]
15311535
def transform(
15321536
self,
15331537
func: AggFuncTypeFrame,

pandas-stubs/core/groupby/generic.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ from pandas.core.series import Series
2929
from typing_extensions import Self
3030

3131
from pandas._libs.tslibs.timestamps import Timestamp
32+
from pandas._typing import (
33+
AggFuncTypeFrame, # pyright: ignore[reportUnknownVariableType]
34+
)
3235
from pandas._typing import (
3336
S2,
3437
S3,
35-
AggFuncTypeBase,
36-
AggFuncTypeFrame,
3738
ByT,
3839
CorrelationMethod,
3940
Dtype,
@@ -48,6 +49,7 @@ from pandas._typing import (
4849
WindowingEngineKwargs,
4950
np_ndarray,
5051
)
52+
from pandas._typing import AggFuncTypeBase # pyright: ignore[reportUnknownVariableType]
5153

5254
AggScalar: TypeAlias = str | Callable[..., Any]
5355

@@ -95,7 +97,7 @@ class SeriesGroupBy(GroupBy[Series[S2]], Generic[S2, ByT]):
9597
engine_kwargs: WindowingEngineKwargs = ...,
9698
**kwargs: Any,
9799
) -> Series: ...
98-
agg = aggregate
100+
agg = aggregate # pyright: ignore[reportUnknownVariableType]
99101
@overload
100102
def transform(
101103
self,
@@ -270,7 +272,7 @@ class DataFrameGroupBy(GroupBy[DataFrame], Generic[ByT, _TT]):
270272
/,
271273
**kwargs: Any,
272274
) -> DataFrame: ...
273-
agg = aggregate
275+
agg = aggregate # pyright: ignore[reportUnknownVariableType]
274276
@overload
275277
def transform(
276278
self,

pandas-stubs/core/reshape/api.pyi

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ from pandas.core.reshape.merge import (
1414
merge_ordered as merge_ordered,
1515
)
1616
from pandas.core.reshape.pivot import (
17-
crosstab as crosstab,
17+
crosstab as crosstab, # pyright: ignore[reportUnknownVariableType]
18+
)
19+
from pandas.core.reshape.pivot import (
1820
pivot as pivot,
19-
pivot_table as pivot_table,
21+
)
22+
from pandas.core.reshape.pivot import (
23+
pivot_table as pivot_table, # pyright: ignore[reportUnknownVariableType]
24+
)
25+
from pandas.core.reshape.tile import (
26+
cut as cut, # pyright: ignore[reportUnknownVariableType]
2027
)
2128
from pandas.core.reshape.tile import (
22-
cut as cut,
2329
qcut as qcut,
2430
)

pandas-stubs/core/reshape/pivot.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ from pandas._typing import (
3333

3434
_PivotAggCallable: TypeAlias = Callable[[Series], ScalarT]
3535

36-
_PivotAggFunc: TypeAlias = (
36+
_PivotAggFunc: TypeAlias = ( # pyright: ignore[reportUnknownVariableType]
3737
_PivotAggCallable
3838
| np.ufunc
3939
| Literal["mean", "sum", "count", "min", "max", "median", "std", "var"]

pandas-stubs/core/series.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ from pandas._libs.lib import _NoDefaultDoNotUse
135135
from pandas._libs.missing import NAType
136136
from pandas._libs.tslibs import BaseOffset
137137
from pandas._libs.tslibs.nattype import NaTType
138+
from pandas._typing import (
139+
AggFuncTypeSeriesToFrame, # pyright: ignore[reportUnknownVariableType]
140+
)
138141
from pandas._typing import (
139142
S1,
140143
S2,
141144
S2_NSDT,
142145
T_COMPLEX,
143-
AggFuncTypeBase,
144146
AggFuncTypeDictFrame,
145-
AggFuncTypeSeriesToFrame,
146147
AnyAll,
147148
AnyArrayLike,
148149
ArrayLike,
@@ -245,6 +246,7 @@ from pandas._typing import (
245246
np_ndarray_str,
246247
np_ndarray_td,
247248
)
249+
from pandas._typing import AggFuncTypeBase # pyright: ignore[reportUnknownVariableType]
248250

249251
from pandas.core.dtypes.base import ExtensionDtype
250252
from pandas.core.dtypes.dtypes import CategoricalDtype
@@ -1147,7 +1149,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
11471149
*args: Any,
11481150
**kwargs: Any,
11491151
) -> Series: ...
1150-
agg = aggregate
1152+
agg = aggregate # pyright: ignore[reportUnknownVariableType]
11511153
@overload
11521154
def transform(
11531155
self,

0 commit comments

Comments
 (0)