Skip to content

Commit a6755d4

Browse files
Improve results of stubtest (#1286)
* Improve results of stubtest * PR Feedback * PR Feedback
1 parent b735e3f commit a6755d4

File tree

5 files changed

+24
-41
lines changed

5 files changed

+24
-41
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,8 +2371,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
23712371
default_handler: Callable[[Any], JSONSerializable] | None = ...,
23722372
lines: Literal[True],
23732373
compression: CompressionOptions = ...,
2374-
index: _bool = ...,
2374+
index: _bool | None = ...,
23752375
indent: int | None = ...,
2376+
storage_options: dict | None = ...,
23762377
mode: Literal["a"],
23772378
) -> None: ...
23782379
@overload
@@ -2388,14 +2389,16 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
23882389
default_handler: Callable[[Any], JSONSerializable] | None = ...,
23892390
lines: Literal[True],
23902391
compression: CompressionOptions = ...,
2391-
index: _bool = ...,
2392+
index: _bool | None = ...,
23922393
indent: int | None = ...,
2394+
storage_options: dict | None = ...,
23932395
mode: Literal["a"],
23942396
) -> _str: ...
23952397
@overload
23962398
def to_json(
23972399
self,
23982400
path_or_buf: None = ...,
2401+
*,
23992402
orient: JsonFrameOrient | None = ...,
24002403
date_format: Literal["epoch", "iso"] | None = ...,
24012404
double_precision: int = ...,
@@ -2404,14 +2407,16 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
24042407
default_handler: Callable[[Any], JSONSerializable] | None = ...,
24052408
lines: _bool = ...,
24062409
compression: CompressionOptions = ...,
2407-
index: _bool = ...,
2410+
index: _bool | None = ...,
24082411
indent: int | None = ...,
2412+
storage_options: dict | None = ...,
24092413
mode: Literal["w"] = ...,
24102414
) -> _str: ...
24112415
@overload
24122416
def to_json(
24132417
self,
24142418
path_or_buf: FilePath | WriteBuffer[str] | WriteBuffer[bytes],
2419+
*,
24152420
orient: JsonFrameOrient | None = ...,
24162421
date_format: Literal["epoch", "iso"] | None = ...,
24172422
double_precision: int = ...,
@@ -2420,8 +2425,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
24202425
default_handler: Callable[[Any], JSONSerializable] | None = ...,
24212426
lines: _bool = ...,
24222427
compression: CompressionOptions = ...,
2423-
index: _bool = ...,
2428+
index: _bool | None = ...,
24242429
indent: int | None = ...,
2430+
storage_options: dict | None = ...,
24252431
mode: Literal["w"] = ...,
24262432
) -> None: ...
24272433
@overload

pandas-stubs/core/series.pyi

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
586586
def to_json(
587587
self,
588588
path_or_buf: FilePath | WriteBuffer[_str] | WriteBuffer[bytes],
589+
*,
589590
orient: JsonSeriesOrient | None = ...,
590591
date_format: Literal["epoch", "iso"] | None = ...,
591592
double_precision: int = ...,
@@ -602,6 +603,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
602603
def to_json(
603604
self,
604605
path_or_buf: None = ...,
606+
*,
605607
orient: JsonSeriesOrient | None = ...,
606608
date_format: Literal["epoch", "iso"] | None = ...,
607609
double_precision: int = ...,
@@ -941,6 +943,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
941943
self,
942944
level: IndexLabel = ...,
943945
fill_value: int | _str | dict | None = ...,
946+
sort: _bool = ...,
944947
) -> DataFrame: ...
945948
@overload
946949
def map(
@@ -1207,6 +1210,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
12071210
figsize: tuple[float, float] | None = ...,
12081211
bins: int | Sequence = ...,
12091212
backend: _str | None = ...,
1213+
legend: _bool = ...,
12101214
**kwargs: Any,
12111215
) -> SubplotBase: ...
12121216
@final
@@ -1217,7 +1221,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
12171221
def droplevel(self, level: Level | list[Level], axis: AxisIndex = ...) -> Self: ...
12181222
def pop(self, item: Hashable) -> S1: ...
12191223
@final
1220-
def squeeze(self) -> Series[S1] | Scalar: ...
1224+
def squeeze(self, axis: None = ...) -> Series[S1] | Scalar: ...
12211225
@final
12221226
def __abs__(self) -> Series[S1]: ...
12231227
@final
@@ -1329,7 +1333,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
13291333
@final
13301334
def copy(self, deep: _bool = ...) -> Series[S1]: ...
13311335
@final
1332-
def infer_objects(self) -> Series[S1]: ...
1336+
def infer_objects(self, copy: _bool = ...) -> Series[S1]: ...
13331337
@overload
13341338
def ffill(
13351339
self,
@@ -1969,7 +1973,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
19691973
self,
19701974
axis: AxisIndex | None = ...,
19711975
skipna: _bool | None = ...,
1972-
level: None = ...,
19731976
numeric_only: _bool = ...,
19741977
min_count: int = ...,
19751978
**kwargs: Any,
@@ -1978,7 +1981,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
19781981
self,
19791982
axis: AxisIndex | None = ...,
19801983
skipna: _bool | None = ...,
1981-
level: None = ...,
19821984
numeric_only: _bool = ...,
19831985
min_count: int = ...,
19841986
**kwargs: Any,
@@ -2078,7 +2080,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
20782080
self,
20792081
axis: AxisIndex | None = ...,
20802082
skipna: _bool | None = ...,
2081-
level: None = ...,
20822083
ddof: int = ...,
20832084
numeric_only: _bool = ...,
20842085
**kwargs: Any,
@@ -2087,15 +2088,13 @@ class Series(IndexOpsMixin[S1], NDFrame):
20872088
self,
20882089
axis: AxisIndex | None = ...,
20892090
skipna: _bool | None = ...,
2090-
level: None = ...,
20912091
numeric_only: _bool = ...,
20922092
**kwargs: Any,
20932093
) -> Scalar: ...
20942094
def std(
20952095
self,
20962096
axis: AxisIndex | None = ...,
20972097
skipna: _bool | None = ...,
2098-
level: None = ...,
20992098
ddof: int = ...,
21002099
numeric_only: _bool = ...,
21012100
**kwargs: Any,
@@ -2114,25 +2113,21 @@ class Series(IndexOpsMixin[S1], NDFrame):
21142113
fill_value: float | None = ...,
21152114
axis: AxisIndex | None = ...,
21162115
) -> Series[S1]: ...
2117-
# ignore needed because of mypy, for using `Never` as type-var.
21182116
@overload
21192117
def sum(
21202118
self: Series[Never],
21212119
axis: AxisIndex | None = ...,
21222120
skipna: _bool | None = ...,
2123-
level: None = ...,
21242121
numeric_only: _bool = ...,
21252122
min_count: int = ...,
21262123
**kwargs: Any,
21272124
) -> Any: ...
2128-
# ignore needed because of mypy, for overlapping overloads
21292125
# between `Series[bool]` and `Series[int]`.
21302126
@overload
21312127
def sum(
21322128
self: Series[bool],
21332129
axis: AxisIndex | None = ...,
21342130
skipna: _bool | None = ...,
2135-
level: None = ...,
21362131
numeric_only: _bool = ...,
21372132
min_count: int = ...,
21382133
**kwargs: Any,
@@ -2142,7 +2137,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
21422137
self: Series[S1],
21432138
axis: AxisIndex | None = ...,
21442139
skipna: _bool | None = ...,
2145-
level: None = ...,
21462140
numeric_only: _bool = ...,
21472141
min_count: int = ...,
21482142
**kwargs: Any,
@@ -2168,7 +2162,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
21682162
self,
21692163
axis: AxisIndex | None = ...,
21702164
skipna: _bool | None = ...,
2171-
level: None = ...,
21722165
ddof: int = ...,
21732166
numeric_only: _bool = ...,
21742167
**kwargs: Any,
@@ -2263,7 +2256,6 @@ class TimestampSeries(Series[Timestamp]):
22632256
self,
22642257
axis: AxisIndex | None = ...,
22652258
skipna: _bool | None = ...,
2266-
level: None = ...,
22672259
ddof: int = ...,
22682260
numeric_only: _bool = ...,
22692261
**kwargs: Any,

pandas-stubs/io/common.pyi

Lines changed: 0 additions & 23 deletions
This file was deleted.

pandas-stubs/io/parquet.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from typing import Any
33
from pandas import DataFrame
44

55
from pandas._typing import (
6+
DtypeBackend,
67
FilePath,
78
ParquetEngine,
89
ReadBuffer,
@@ -14,5 +15,8 @@ def read_parquet(
1415
engine: ParquetEngine = ...,
1516
columns: list[str] | None = ...,
1617
storage_options: StorageOptions = ...,
18+
dtype_backend: DtypeBackend = ...,
19+
filesystem: Any = None,
20+
filters: list[tuple] | list[list[tuple]] | None = None,
1721
**kwargs: Any,
1822
) -> DataFrame: ...

tests/test_io.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ def test_parquet_options():
546546
type(None),
547547
)
548548
check(assert_type(read_parquet(path), DataFrame), DataFrame)
549+
check(assert_type(read_parquet(path), DataFrame), DataFrame)
550+
551+
sel = [("a", ">", 2)]
552+
check(assert_type(read_parquet(path, filters=sel), DataFrame), DataFrame)
549553

550554

551555
def test_feather():

0 commit comments

Comments
 (0)