Skip to content

Commit cf09bf8

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 23b82e2 commit cf09bf8

Some content is hidden

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

68 files changed

+753
-713
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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ from pandas.core.api import (
4747
UInt16Dtype as UInt16Dtype,
4848
UInt32Dtype as UInt32Dtype,
4949
UInt64Dtype as UInt64Dtype,
50-
array as array,
5150
bdate_range as bdate_range,
5251
date_range as date_range,
5352
factorize as factorize,
@@ -66,6 +65,7 @@ from pandas.core.api import (
6665
)
6766
from pandas.core.arrays.sparse import SparseDtype as SparseDtype
6867
from pandas.core.computation.api import eval as eval
68+
from pandas.core.construction import array as array
6969
from pandas.core.reshape.api import (
7070
concat as concat,
7171
crosstab as crosstab,
@@ -100,13 +100,11 @@ from pandas.io.api import (
100100
HDFStore as HDFStore,
101101
read_clipboard as read_clipboard,
102102
read_csv as read_csv,
103-
read_excel as read_excel,
104103
read_feather as read_feather,
105104
read_fwf as read_fwf,
106105
read_hdf as read_hdf,
107106
read_html as read_html,
108107
read_json as read_json,
109-
read_orc as read_orc,
110108
read_parquet as read_parquet,
111109
read_pickle as read_pickle,
112110
read_sas as read_sas,
@@ -118,6 +116,12 @@ from pandas.io.api import (
118116
read_table as read_table,
119117
read_xml as read_xml,
120118
)
119+
from pandas.io.api import (
120+
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
121+
)
122+
from pandas.io.api import (
123+
read_orc as read_orc, # pyright: ignore[reportUnknownVariableType]
124+
)
121125
from pandas.io.json._normalize import json_normalize as json_normalize
122126
from pandas.tseries import offsets as offsets
123127
from pandas.tseries.api import infer_freq as infer_freq

pandas-stubs/core/frame.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
11931193
@overload
11941194
def sort_values(
11951195
self,
1196-
by: _str | Sequence[_str],
1196+
by: _str | SequenceNotStr[_str],
11971197
*,
11981198
axis: Axis = 0,
11991199
ascending: _bool | Sequence[_bool] = ...,
@@ -1206,7 +1206,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
12061206
@overload
12071207
def sort_values(
12081208
self,
1209-
by: _str | Sequence[_str],
1209+
by: _str | SequenceNotStr[_str],
12101210
*,
12111211
axis: Axis = 0,
12121212
ascending: _bool | Sequence[_bool] = ...,
@@ -1413,7 +1413,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14131413
@overload
14141414
def groupby( # type: ignore[overload-overlap] # pyright: ignore reportOverlappingOverload
14151415
self,
1416-
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1416+
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
14171417
level: IndexLabel | None = ...,
14181418
as_index: Literal[True] = True,
14191419
sort: _bool = ...,
@@ -1424,7 +1424,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
14241424
@overload
14251425
def groupby( # type: ignore[overload-overlap]
14261426
self,
1427-
by: MultiIndex | GroupByObjectNonScalar | None = ...,
1427+
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
14281428
level: IndexLabel | None = ...,
14291429
as_index: Literal[False] = False,
14301430
sort: _bool = ...,
@@ -1882,7 +1882,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18821882
@overload
18831883
def boxplot(
18841884
self,
1885-
by: Hashable | ListLikeHashable,
1885+
by: Hashable | ListLikeHashable[Hashable],
18861886
ax: PlotAxes | None = None,
18871887
fontsize: float | _str | None = None,
18881888
rot: float = 0,
@@ -1897,7 +1897,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18971897
@overload
18981898
def boxplot(
18991899
self,
1900-
by: Hashable | ListLikeHashable,
1900+
by: Hashable | ListLikeHashable[Hashable],
19011901
ax: PlotAxes | None = None,
19021902
fontsize: float | _str | None = None,
19031903
rot: float = 0,

pandas-stubs/core/reshape/tile.pyi

Lines changed: 10 additions & 3 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
)
@@ -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 = ...,

pandas-stubs/io/json/__init__.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from pandas.io.json._json import (
2-
read_json as read_json,
3-
)
1+
from pandas.io.json._json import read_json as read_json
42

53
# below are untyped imports so commented out
64
# to_json as to_json,; ujson_dumps as ujson_dumps,; ujson_loads as ujson_loads,

pandas-stubs/io/orc.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Any
22

3-
from fsspec.spec import AbstractFileSystem # pyright: ignore[reportMissingTypeStubs]
43
from pandas import DataFrame
54
from pyarrow.fs import FileSystem
65

@@ -12,6 +11,10 @@ from pandas._typing import (
1211
ReadBuffer,
1312
)
1413

14+
from fsspec.spec import ( # pyright: ignore[reportMissingTypeStubs] # isort: skip
15+
AbstractFileSystem, # pyright: ignore[reportUnknownVariableType]
16+
)
17+
1518
def read_orc(
1619
path: FilePath | ReadBuffer[bytes],
1720
columns: list[HashableT] | None = None,

0 commit comments

Comments
 (0)