Skip to content

Commit eda7945

Browse files
committed
MAINT: Merge main
2 parents 99e4203 + 1293443 commit eda7945

File tree

11 files changed

+673
-754
lines changed

11 files changed

+673
-754
lines changed

docs/tests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Here are the most important options. Fore more details, please use `poe --help`.
1111
- Run only pytest: `poe pytest`
1212
- Run only pre-commit: `poe style`
1313
- Run tests against the installed stubs (this will install and uninstall the stubs): `poe test_dist`
14+
- Optional: run pytest against pandas nightly (this might fail): `poe pytest --nightly`
1415
- Optional: Run stubtest to compare the installed pandas-stubs against pandas (this will fail): `poe stubtest`. If you have created an allowlist to ignore certain errors: `poe stubtest path_to_the_allow_list`
1516

1617
These tests originally came from https://github.com/VirtusLab/pandas-stubs.

pandas-stubs/_typing.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ from typing import (
1414
AnyStr,
1515
Callable,
1616
Hashable,
17+
Iterator,
1718
Literal,
1819
Mapping,
1920
Optional,
@@ -69,6 +70,12 @@ class WriteBuffer(BaseBuffer, Protocol[AnyStr_cov]): ...
6970
class ReadPickleBuffer(ReadBuffer[bytes], Protocol):
7071
def readline(self, size: int | None = ...) -> bytes: ...
7172

73+
class ReadCsvBuffer(ReadBuffer[AnyStr_cov], Protocol[AnyStr_cov]):
74+
def __iter__(self) -> Iterator[AnyStr_cov]: ...
75+
def readline(self) -> AnyStr_cov: ...
76+
@property
77+
def closed(self) -> bool: ...
78+
7279
class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
7380
def truncate(self, size: Union[int, None] = ...) -> int: ...
7481

@@ -245,6 +252,7 @@ JsonSeriesOrient = Literal["split", "records", "index"]
245252
TimestampConvention = Literal["start", "end", "s", "e"]
246253

247254
CSVEngine = Literal["c", "python", "pyarrow", "python-fwf"]
255+
CSVQuoting = Literal[0, 1, 2, 3]
248256

249257
HDFCompLib = Literal["zlib", "lzo", "bzip2", "blosc"]
250258
ParquetEngine = Literal["auto", "pyarrow", "fastparquet"]

pandas-stubs/core/frame.pyi

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,55 +1917,6 @@ class DataFrame(NDFrame, OpsMixin):
19171917
self, excel: _bool = ..., sep: _str | None = ..., **kwargs
19181918
) -> None: ...
19191919
@overload
1920-
def to_csv(
1921-
self,
1922-
path_or_buf: FilePathOrBuffer | None,
1923-
sep: _str = ...,
1924-
na_rep: _str = ...,
1925-
float_format: _str | None = ...,
1926-
columns: Sequence[Hashable] | None = ...,
1927-
header: _bool | list[_str] = ...,
1928-
index: _bool = ...,
1929-
index_label: _bool | _str | Sequence[Hashable] | None = ...,
1930-
mode: _str = ...,
1931-
encoding: _str | None = ...,
1932-
compression: _str | Mapping[_str, _str] = ...,
1933-
quoting: Literal[0, 1, 2, 3] | None = ...,
1934-
quotechar: _str = ...,
1935-
line_terminator: _str | None = ...,
1936-
chunksize: int | None = ...,
1937-
date_format: _str | None = ...,
1938-
doublequote: _bool = ...,
1939-
escapechar: _str | None = ...,
1940-
decimal: _str = ...,
1941-
errors: _str = ...,
1942-
storage_options: dict[_str, Any] | None = ...,
1943-
) -> None: ...
1944-
@overload
1945-
def to_csv(
1946-
self,
1947-
sep: _str = ...,
1948-
na_rep: _str = ...,
1949-
float_format: _str | None = ...,
1950-
columns: Sequence[Hashable] | None = ...,
1951-
header: _bool | list[_str] = ...,
1952-
index: _bool = ...,
1953-
index_label: _bool | _str | Sequence[Hashable] | None = ...,
1954-
mode: _str = ...,
1955-
encoding: _str | None = ...,
1956-
compression: _str | Mapping[_str, _str] = ...,
1957-
quoting: Literal[0, 1, 2, 3] | None = ...,
1958-
quotechar: _str = ...,
1959-
line_terminator: _str | None = ...,
1960-
chunksize: int | None = ...,
1961-
date_format: _str | None = ...,
1962-
doublequote: _bool = ...,
1963-
escapechar: _str | None = ...,
1964-
decimal: _str = ...,
1965-
errors: _str = ...,
1966-
storage_options: dict[_str, Any] | None = ...,
1967-
) -> _str: ...
1968-
@overload
19691920
def to_json(
19701921
self,
19711922
path_or_buf: FilePathOrBuffer | None,

pandas-stubs/core/generic.pyi

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from pandas._typing import (
2222
ArrayLike,
2323
Axis,
2424
CompressionOptions,
25+
CSVQuoting,
2526
Dtype,
2627
DtypeArg,
2728
FilePath,
@@ -233,18 +234,18 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
233234
@overload
234235
def to_csv(
235236
self,
236-
path_or_buf: FilePathOrBuffer | None,
237+
path_or_buf: FilePathOrBuffer,
237238
sep: _str = ...,
238239
na_rep: _str = ...,
239-
float_format: _str | None = ...,
240-
columns: Sequence[Hashable] | None = ...,
240+
float_format: _str | Callable[[object], _str] | None = ...,
241+
columns: list[HashableT] | None = ...,
241242
header: _bool | list[_str] = ...,
242243
index: _bool = ...,
243-
index_label: _bool | _str | Sequence[Hashable] | None = ...,
244-
mode: _str = ...,
244+
index_label: Literal[False] | _str | list[HashableT] | None = ...,
245+
mode: FileWriteMode = ...,
245246
encoding: _str | None = ...,
246-
compression: _str | Mapping[_str, _str] = ...,
247-
quoting: Literal[0, 1, 2, 3] | None = ...,
247+
compression: CompressionOptions = ...,
248+
quoting: CSVQuoting = ...,
248249
quotechar: _str = ...,
249250
line_terminator: _str | None = ...,
250251
chunksize: int | None = ...,
@@ -253,22 +254,23 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
253254
escapechar: _str | None = ...,
254255
decimal: _str = ...,
255256
errors: _str = ...,
256-
storage_options: dict[_str, Any] | None = ...,
257+
storage_options: StorageOptions = ...,
257258
) -> None: ...
258259
@overload
259260
def to_csv(
260261
self,
262+
path_or_buf: None = ...,
261263
sep: _str = ...,
262264
na_rep: _str = ...,
263-
float_format: _str | None = ...,
264-
columns: Sequence[Hashable] | None = ...,
265+
float_format: _str | Callable[[object], _str] | None = ...,
266+
columns: list[HashableT] | None = ...,
265267
header: _bool | list[_str] = ...,
266268
index: _bool = ...,
267-
index_label: _bool | _str | Sequence[Hashable] | None = ...,
268-
mode: _str = ...,
269+
index_label: Literal[False] | _str | list[HashableT] | None = ...,
270+
mode: FileWriteMode = ...,
269271
encoding: _str | None = ...,
270-
compression: _str | Mapping[_str, _str] = ...,
271-
quoting: Literal[0, 1, 2, 3] | None = ...,
272+
compression: CompressionOptions = ...,
273+
quoting: CSVQuoting = ...,
272274
quotechar: _str = ...,
273275
line_terminator: _str | None = ...,
274276
chunksize: int | None = ...,
@@ -277,7 +279,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
277279
escapechar: _str | None = ...,
278280
decimal: _str = ...,
279281
errors: _str = ...,
280-
storage_options: dict[_str, Any] | None = ...,
282+
storage_options: StorageOptions = ...,
281283
) -> _str: ...
282284
def take(
283285
self, indices, axis=..., is_copy: _bool | None = ..., **kwargs

pandas-stubs/io/clipboards.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from pandas.core.series import Series
1515
from pandas._typing import (
1616
CompressionOptions,
1717
CSVEngine,
18+
CSVQuoting,
1819
DtypeArg,
1920
StorageOptions,
2021
npt,
@@ -71,7 +72,7 @@ def read_clipboard(
7172
decimal: str = ...,
7273
lineterminator: str | None = ...,
7374
quotechar: str = ...,
74-
quoting: Literal[0, 1, 2, 3] | None = ...,
75+
quoting: CSVQuoting = ...,
7576
doublequote: bool = ...,
7677
escapechar: str | None = ...,
7778
comment: str | None = ...,
@@ -137,7 +138,7 @@ def read_clipboard(
137138
decimal: str = ...,
138139
lineterminator: str | None = ...,
139140
quotechar: str = ...,
140-
quoting: Literal[0, 1, 2, 3] | None = ...,
141+
quoting: CSVQuoting = ...,
141142
doublequote: bool = ...,
142143
escapechar: str | None = ...,
143144
comment: str | None = ...,
@@ -203,7 +204,7 @@ def read_clipboard(
203204
decimal: str = ...,
204205
lineterminator: str | None = ...,
205206
quotechar: str = ...,
206-
quoting: Literal[0, 1, 2, 3] | None = ...,
207+
quoting: CSVQuoting = ...,
207208
doublequote: bool = ...,
208209
escapechar: str | None = ...,
209210
comment: str | None = ...,

pandas-stubs/io/common.pyi

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
from typing import (
2-
IO,
3-
AnyStr,
4-
Generic,
5-
)
6-
7-
from pandas._typing import CompressionDict
8-
9-
class IOHandles(Generic[AnyStr]):
10-
handle: IO[AnyStr]
11-
compression: CompressionDict
12-
created_handles: list[IO[AnyStr]]
13-
is_wrapped: bool
14-
def close(self) -> None: ...
15-
def __enter__(self) -> IOHandles[AnyStr]: ...
16-
def __exit__(self, *args: object) -> None: ...
17-
def __init__(self, handle, compression, created_handles, is_wrapped) -> None: ...
1+
from typing import (
2+
IO,
3+
AnyStr,
4+
Generic,
5+
)
6+
7+
from pandas._typing import CompressionDict
8+
9+
class IOHandles(Generic[AnyStr]):
10+
handle: IO[AnyStr]
11+
compression: CompressionDict
12+
created_handles: list[IO[AnyStr]]
13+
is_wrapped: bool
14+
def close(self) -> None: ...
15+
def __enter__(self) -> IOHandles[AnyStr]: ...
16+
def __exit__(self, *args: object) -> None: ...
17+
def __init__(self, handle, compression, created_handles, is_wrapped) -> None: ...

0 commit comments

Comments
 (0)