Skip to content

Commit b610573

Browse files
committed
enable reportUnknownVariableType
psf black 4880 black pyright @ py310 reduce AggFuncType read_table, read_csv read_clipboard, read_xml read_html, read_parquet read_sql, read_sql_query read_json, build_table_schema, json_normalize to_timedelta, eval value_counts, crosstab cut, pivot_table agg mypy, ty groupby pyright for value_counts pyright mypy
1 parent d904a17 commit b610573

Some content is hidden

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

75 files changed

+807
-726
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: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
from pandas import (
24
api as api,
35
arrays as arrays,
@@ -47,7 +49,6 @@ from pandas.core.api import (
4749
UInt16Dtype as UInt16Dtype,
4850
UInt32Dtype as UInt32Dtype,
4951
UInt64Dtype as UInt64Dtype,
50-
array as array,
5152
bdate_range as bdate_range,
5253
date_range as date_range,
5354
factorize as factorize,
@@ -100,13 +101,11 @@ from pandas.io.api import (
100101
HDFStore as HDFStore,
101102
read_clipboard as read_clipboard,
102103
read_csv as read_csv,
103-
read_excel as read_excel,
104104
read_feather as read_feather,
105105
read_fwf as read_fwf,
106106
read_hdf as read_hdf,
107107
read_html as read_html,
108108
read_json as read_json,
109-
read_orc as read_orc,
110109
read_parquet as read_parquet,
111110
read_pickle as read_pickle,
112111
read_sas as read_sas,
@@ -118,8 +117,21 @@ from pandas.io.api import (
118117
read_table as read_table,
119118
read_xml as read_xml,
120119
)
120+
from pandas.io.api import (
121+
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
122+
)
123+
from pandas.io.api import (
124+
read_orc as read_orc, # pyright: ignore[reportUnknownVariableType]
125+
)
121126
from pandas.io.json._normalize import json_normalize as json_normalize
122127
from pandas.tseries import offsets as offsets
123128
from pandas.tseries.api import infer_freq as infer_freq
124129

130+
if sys.version_info >= (3, 11):
131+
from pandas.core.construction import array as array
132+
else:
133+
from pandas.core.construction import (
134+
array as array, # pyright: ignore[reportUnknownVariableType]
135+
)
136+
125137
__version__: str

pandas-stubs/_typing.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -967,9 +967,7 @@ ListLikeExceptSeriesAndStr: TypeAlias = (
967967
MutableSequence[Any] | np_1darray | tuple[Any, ...] | Index
968968
)
969969
ListLikeU: TypeAlias = Sequence[Any] | np_1darray | Series | Index
970-
ListLikeHashable: TypeAlias = (
971-
MutableSequence[HashableT] | np_1darray | tuple[HashableT, ...] | range
972-
)
970+
ListLikeHashable: TypeAlias = SequenceNotStr[HashableT] | np_1darray | range
973971

974972
class SupportsDType(Protocol[GenericT_co]):
975973
@property

pandas-stubs/core/api.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
from pandas.core.algorithms import (
24
factorize as factorize,
35
unique as unique,
@@ -20,7 +22,6 @@ from pandas.core.arrays.integer import (
2022
UInt64Dtype as UInt64Dtype,
2123
)
2224
from pandas.core.arrays.string_ import StringDtype as StringDtype
23-
from pandas.core.construction import array as array
2425
from pandas.core.frame import DataFrame as DataFrame
2526
from pandas.core.groupby import (
2627
Grouper as Grouper,
@@ -75,3 +76,10 @@ from pandas.core.dtypes.missing import (
7576

7677
from pandas.io.formats.format import set_eng_float_format as set_eng_float_format
7778
from pandas.tseries.offsets import DateOffset as DateOffset
79+
80+
if sys.version_info >= (3, 11):
81+
from pandas.core.construction import array as array
82+
else:
83+
from pandas.core.construction import (
84+
array as array, # pyright: ignore[reportUnknownVariableType]
85+
)

pandas-stubs/core/frame.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
11851185
@overload
11861186
def sort_values(
11871187
self,
1188-
by: _str | Sequence[_str],
1188+
by: _str | SequenceNotStr[_str],
11891189
*,
11901190
axis: Axis = 0,
11911191
ascending: _bool | Sequence[_bool] = ...,
@@ -1198,7 +1198,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
11981198
@overload
11991199
def sort_values(
12001200
self,
1201-
by: _str | Sequence[_str],
1201+
by: _str | SequenceNotStr[_str],
12021202
*,
12031203
axis: Axis = 0,
12041204
ascending: _bool | Sequence[_bool] = ...,
@@ -1405,7 +1405,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14051405
@overload
14061406
def groupby( # type: ignore[overload-overlap] # pyright: ignore reportOverlappingOverload
14071407
self,
1408-
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1408+
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
14091409
level: IndexLabel | None = ...,
14101410
as_index: Literal[True] = True,
14111411
sort: _bool = ...,
@@ -1416,7 +1416,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14161416
@overload
14171417
def groupby( # type: ignore[overload-overlap]
14181418
self,
1419-
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1419+
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
14201420
level: IndexLabel | None = ...,
14211421
as_index: Literal[False] = False,
14221422
sort: _bool = ...,
@@ -1876,7 +1876,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18761876
@overload
18771877
def boxplot(
18781878
self,
1879-
by: Hashable | ListLikeHashable,
1879+
by: Hashable | ListLikeHashable[Hashable],
18801880
ax: PlotAxes | None = None,
18811881
fontsize: float | _str | None = None,
18821882
rot: float = 0,
@@ -1891,7 +1891,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18911891
@overload
18921892
def boxplot(
18931893
self,
1894-
by: Hashable | ListLikeHashable,
1894+
by: Hashable | ListLikeHashable[Hashable],
18951895
ax: PlotAxes | None = None,
18961896
fontsize: float | _str | None = None,
18971897
rot: float = 0,

pandas-stubs/core/reshape/tile.pyi

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections.abc import Sequence
22
from typing import (
3+
Any,
34
Literal,
45
overload,
56
)
@@ -102,7 +103,7 @@ def cut(
102103
include_lowest: bool = ...,
103104
duplicates: Literal["raise", "drop"] = ...,
104105
ordered: bool = ...,
105-
) -> tuple[Series, IntervalIndex]: ...
106+
) -> tuple[Series, IntervalIndex[Any]]: ...
106107
@overload
107108
def cut(
108109
x: Sequence[float] | np_ndarray_anyint | np_ndarray_float | Index,
@@ -132,7 +133,9 @@ def cut(
132133
@overload
133134
def cut(
134135
x: Sequence[float] | np_ndarray_anyint | np_ndarray_float | Index,
135-
bins: int | Sequence[float] | Index[int] | Index[float] | IntervalIndex | Series,
136+
bins: (
137+
int | Sequence[float] | Index[int] | Index[float] | IntervalIndex[Any] | Series
138+
),
136139
right: bool = ...,
137140
*,
138141
labels: Literal[False],
@@ -163,7 +166,9 @@ def cut(
163166
@overload
164167
def cut(
165168
x: Series,
166-
bins: int | Sequence[float] | Index[int] | Index[float] | IntervalIndex | Series,
169+
bins: (
170+
int | Sequence[float] | Index[int] | Index[float] | IntervalIndex[Any] | Series
171+
),
167172
right: bool = ...,
168173
labels: Literal[False] | Sequence[Label] | None = ...,
169174
retbins: Literal[False] = False,
@@ -175,7 +180,9 @@ def cut(
175180
@overload
176181
def cut(
177182
x: Sequence[float] | np_ndarray_anyint | np_ndarray_float | Index,
178-
bins: int | Sequence[float] | Index[int] | Index[float] | IntervalIndex | Series,
183+
bins: (
184+
int | Sequence[float] | Index[int] | Index[float] | IntervalIndex[Any] | Series
185+
),
179186
right: bool = ...,
180187
labels: Sequence[Label] | None = ...,
181188
retbins: Literal[False] = False,

pandas-stubs/io/api.pyi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ from pandas.io.clipboards import read_clipboard as read_clipboard
22
from pandas.io.excel import (
33
ExcelFile as ExcelFile,
44
ExcelWriter as ExcelWriter,
5-
read_excel as read_excel,
5+
)
6+
from pandas.io.excel import (
7+
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
68
)
79
from pandas.io.feather_format import read_feather as read_feather
810
from pandas.io.html import read_html as read_html
911
from pandas.io.json import read_json as read_json
10-
from pandas.io.orc import read_orc as read_orc
12+
from pandas.io.orc import (
13+
read_orc as read_orc, # pyright: ignore[reportUnknownVariableType]
14+
)
1115
from pandas.io.parquet import read_parquet as read_parquet
12-
from pandas.io.parsers import (
16+
from pandas.io.parsers.readers import (
1317
read_csv as read_csv,
1418
read_fwf as read_fwf,
1519
read_table as read_table,

pandas-stubs/io/clipboards.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections import defaultdict
22
from collections.abc import (
33
Callable,
4+
Hashable,
45
Sequence,
56
)
67
import csv
@@ -33,9 +34,9 @@ def read_clipboard(
3334
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ...,
3435
delimiter: str | None = ...,
3536
header: int | Sequence[int] | Literal["infer"] | None = ...,
36-
names: ListLikeHashable | None = ...,
37+
names: ListLikeHashable[Hashable] | None = ...,
3738
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
38-
usecols: UsecolsArgType = ...,
39+
usecols: UsecolsArgType[Any] = ...,
3940
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
4041
engine: CSVEngine | None = ...,
4142
converters: dict[int | str, Callable[[str], Any]] = ...,
@@ -92,9 +93,9 @@ def read_clipboard(
9293
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ...,
9394
delimiter: str | None = ...,
9495
header: int | Sequence[int] | Literal["infer"] | None = ...,
95-
names: ListLikeHashable | None = ...,
96+
names: ListLikeHashable[Hashable] | None = ...,
9697
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
97-
usecols: UsecolsArgType = ...,
98+
usecols: UsecolsArgType[Any] = ...,
9899
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
99100
engine: CSVEngine | None = ...,
100101
converters: dict[int | str, Callable[[str], Any]] = ...,
@@ -151,9 +152,9 @@ def read_clipboard(
151152
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ...,
152153
delimiter: str | None = ...,
153154
header: int | Sequence[int] | Literal["infer"] | None = ...,
154-
names: ListLikeHashable | None = ...,
155+
names: ListLikeHashable[Hashable] | None = ...,
155156
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
156-
usecols: UsecolsArgType = ...,
157+
usecols: UsecolsArgType[Any] = ...,
157158
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
158159
engine: CSVEngine | None = ...,
159160
converters: dict[int | str, Callable[[str], Any]] = ...,

pandas-stubs/io/excel/__init__.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pandas.io.excel._base import (
22
ExcelFile as ExcelFile,
33
ExcelWriter as ExcelWriter,
4-
read_excel as read_excel,
4+
)
5+
from pandas.io.excel._base import (
6+
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
57
)

pandas-stubs/io/excel/_base.pyi

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ from typing import (
1212
overload,
1313
)
1414

15-
from odf.opendocument import OpenDocument # pyright: ignore[reportMissingTypeStubs]
1615
from openpyxl.workbook.workbook import Workbook
1716
from pandas.core.frame import DataFrame
1817
import pyxlsb.workbook # pyright: ignore[reportMissingTypeStubs]
@@ -35,6 +34,10 @@ from pandas._typing import (
3534
WriteExcelBuffer,
3635
)
3736

37+
from odf.opendocument import ( # pyright: ignore[reportMissingTypeStubs] # isort: skip
38+
OpenDocument, # pyright: ignore[reportUnknownVariableType]
39+
)
40+
3841
@overload
3942
def read_excel(
4043
io: (
@@ -49,9 +52,9 @@ def read_excel(
4952
sheet_name: list[IntStrT],
5053
*,
5154
header: int | Sequence[int] | None = ...,
52-
names: ListLikeHashable | None = ...,
55+
names: ListLikeHashable[Hashable] | None = ...,
5356
index_col: int | Sequence[int] | str | None = ...,
54-
usecols: str | UsecolsArgType = ...,
57+
usecols: str | UsecolsArgType[Any] = ...,
5558
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
5659
engine: ExcelReadEngine | None = ...,
5760
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
@@ -92,9 +95,9 @@ def read_excel(
9295
sheet_name: None,
9396
*,
9497
header: int | Sequence[int] | None = ...,
95-
names: ListLikeHashable | None = ...,
98+
names: ListLikeHashable[Hashable] | None = ...,
9699
index_col: int | Sequence[int] | str | None = ...,
97-
usecols: str | UsecolsArgType = ...,
100+
usecols: str | UsecolsArgType[Any] = ...,
98101
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
99102
engine: ExcelReadEngine | None = ...,
100103
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
@@ -136,9 +139,9 @@ def read_excel( # type: ignore[overload-cannot-match]
136139
sheet_name: list[int | str],
137140
*,
138141
header: int | Sequence[int] | None = ...,
139-
names: ListLikeHashable | None = ...,
142+
names: ListLikeHashable[Hashable] | None = ...,
140143
index_col: int | Sequence[int] | str | None = ...,
141-
usecols: str | UsecolsArgType = ...,
144+
usecols: str | UsecolsArgType[Any] = ...,
142145
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
143146
engine: ExcelReadEngine | None = ...,
144147
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
@@ -179,9 +182,9 @@ def read_excel(
179182
sheet_name: int | str = ...,
180183
*,
181184
header: int | Sequence[int] | None = ...,
182-
names: ListLikeHashable | None = ...,
185+
names: ListLikeHashable[Hashable] | None = ...,
183186
index_col: int | Sequence[int] | str | None = ...,
184-
usecols: str | UsecolsArgType = ...,
187+
usecols: str | UsecolsArgType[Any] = ...,
185188
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
186189
engine: ExcelReadEngine | None = ...,
187190
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
@@ -261,9 +264,9 @@ class ExcelFile:
261264
self,
262265
sheet_name: list[int | str] | None,
263266
header: int | Sequence[int] | None = ...,
264-
names: ListLikeHashable | None = ...,
267+
names: ListLikeHashable[Hashable] | None = ...,
265268
index_col: int | Sequence[int] | None = ...,
266-
usecols: str | UsecolsArgType = ...,
269+
usecols: str | UsecolsArgType[Any] = ...,
267270
converters: dict[int | str, Callable[[Any], Any]] | None = ...,
268271
true_values: Iterable[Hashable] | None = ...,
269272
false_values: Iterable[Hashable] | None = ...,
@@ -289,9 +292,9 @@ class ExcelFile:
289292
self,
290293
sheet_name: int | str,
291294
header: int | Sequence[int] | None = ...,
292-
names: ListLikeHashable | None = ...,
295+
names: ListLikeHashable[Hashable] | None = ...,
293296
index_col: int | Sequence[int] | None = ...,
294-
usecols: str | UsecolsArgType = ...,
297+
usecols: str | UsecolsArgType[Any] = ...,
295298
converters: dict[int | str, Callable[[Any], Any]] | None = ...,
296299
true_values: Iterable[Hashable] | None = ...,
297300
false_values: Iterable[Hashable] | None = ...,

0 commit comments

Comments
 (0)