Skip to content

Commit 99e4203

Browse files
author
Kevin Sheppard
committed
MAINT: Merge master
2 parents bb42347 + 6e002f8 commit 99e4203

File tree

15 files changed

+414
-204
lines changed

15 files changed

+414
-204
lines changed

pandas-stubs/_typing.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ from pandas._libs.tslibs import (
3939

4040
from pandas.core.dtypes.dtypes import ExtensionDtype
4141

42+
from pandas.io.formats.format import EngFormatter
43+
4244
ArrayLike = Union[ExtensionArray, np.ndarray]
4345
AnyArrayLike = Union[Index, Series, np.ndarray]
4446
PythonScalar = Union[str, bool, complex]
4547
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", Period, Timestamp, Timedelta)
4648
PandasScalar = Union[bytes, datetime.date, datetime.datetime, datetime.timedelta]
4749
# Scalar = Union[PythonScalar, PandasScalar]
48-
IntStrT = TypeVar("IntStrT", int, str)
4950

5051
DatetimeLike = Union[datetime.date, datetime.datetime, np.datetime64, Timestamp]
5152

@@ -68,6 +69,9 @@ class WriteBuffer(BaseBuffer, Protocol[AnyStr_cov]): ...
6869
class ReadPickleBuffer(ReadBuffer[bytes], Protocol):
6970
def readline(self, size: int | None = ...) -> bytes: ...
7071

72+
class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
73+
def truncate(self, size: Union[int, None] = ...) -> int: ...
74+
7175
FilePath = Union[str, PathLike[str]]
7276

7377
Buffer = Union[IO[AnyStr], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap]
@@ -191,7 +195,10 @@ CompressionDict = dict[str, Any]
191195
CompressionOptions = Optional[
192196
Union[Literal["infer", "gzip", "bz2", "zip", "xz", "zstd"], CompressionDict]
193197
]
194-
198+
FormattersType = Union[
199+
list[Callable], tuple[Callable, ...], Mapping[Union[str, int], Callable]
200+
]
201+
FloatFormatType = str | Callable | EngFormatter
195202
# converters
196203
ConvertersArg = dict[Hashable, Callable[[Dtype], Dtype]]
197204

pandas-stubs/core/dtypes/generic.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pandas import (
2+
DataFrame,
3+
Index,
4+
Series,
5+
)
6+
from pandas.core.arrays import ExtensionArray
7+
from pandas.core.generic import NDFrame
8+
9+
ABCIndex = type[Index]
10+
11+
ABCNDFrame = type[NDFrame]
12+
ABCSeries = type[Series]
13+
ABCDataFrame = type[DataFrame]
14+
15+
ABCExtensionArray = type[ExtensionArray]

pandas-stubs/core/frame.pyi

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ from pandas._typing import (
5757
FilePath,
5858
FilePathOrBuffer,
5959
FillnaOptions,
60+
FloatFormatType,
61+
FormattersType,
6062
GroupByObjectNonScalar,
6163
HashableT,
6264
IgnoreRaise,
@@ -347,7 +349,7 @@ class DataFrame(NDFrame, OpsMixin):
347349
def to_html(
348350
self,
349351
buf: FilePath | WriteBuffer[str],
350-
columns: list[HashableT] | None = ...,
352+
columns: list[HashableT] | Index | Series | None = ...,
351353
col_space: ColspaceArgType | None = ...,
352354
header: _bool = ...,
353355
index: _bool = ...,
@@ -1928,7 +1930,7 @@ class DataFrame(NDFrame, OpsMixin):
19281930
mode: _str = ...,
19291931
encoding: _str | None = ...,
19301932
compression: _str | Mapping[_str, _str] = ...,
1931-
quoting: int | None = ...,
1933+
quoting: Literal[0, 1, 2, 3] | None = ...,
19321934
quotechar: _str = ...,
19331935
line_terminator: _str | None = ...,
19341936
chunksize: int | None = ...,
@@ -1952,7 +1954,7 @@ class DataFrame(NDFrame, OpsMixin):
19521954
mode: _str = ...,
19531955
encoding: _str | None = ...,
19541956
compression: _str | Mapping[_str, _str] = ...,
1955-
quoting: int | None = ...,
1957+
quoting: Literal[0, 1, 2, 3] | None = ...,
19561958
quotechar: _str = ...,
19571959
line_terminator: _str | None = ...,
19581960
chunksize: int | None = ...,
@@ -1997,45 +1999,46 @@ class DataFrame(NDFrame, OpsMixin):
19971999
@overload
19982000
def to_string(
19992001
self,
2000-
buf: FilePathOrBuffer | None,
2001-
columns: Sequence[_str] | None = ...,
2002-
col_space: int | list[int] | dict[_str | int, int] | None = ...,
2003-
header: _bool | Sequence[_str] = ...,
2002+
buf: FilePath | WriteBuffer[str],
2003+
columns: list[HashableT] | Index | Series | None = ...,
2004+
col_space: int | list[int] | dict[HashableT, int] | None = ...,
2005+
header: _bool | list[_str] | tuple[str, ...] = ...,
20042006
index: _bool = ...,
20052007
na_rep: _str = ...,
2006-
formatters=...,
2007-
float_format=...,
2008+
formatters: FormattersType | None = ...,
2009+
float_format: FloatFormatType | None = ...,
20082010
sparsify: _bool | None = ...,
20092011
index_names: _bool = ...,
20102012
justify: _str | None = ...,
20112013
max_rows: int | None = ...,
2012-
min_rows: int | None = ...,
20132014
max_cols: int | None = ...,
20142015
show_dimensions: _bool = ...,
20152016
decimal: _str = ...,
20162017
line_width: int | None = ...,
2018+
min_rows: int | None = ...,
20172019
max_colwidth: int | None = ...,
20182020
encoding: _str | None = ...,
20192021
) -> None: ...
20202022
@overload
20212023
def to_string(
20222024
self,
2023-
columns: Sequence[_str] | None = ...,
2024-
col_space: int | list[int] | dict[_str | int, int] | None = ...,
2025+
buf: None = ...,
2026+
columns: list[HashableT] | Index | Series | None = ...,
2027+
col_space: int | list[int] | dict[Hashable, int] | None = ...,
20252028
header: _bool | Sequence[_str] = ...,
20262029
index: _bool = ...,
20272030
na_rep: _str = ...,
2028-
formatters=...,
2029-
float_format=...,
2031+
formatters: FormattersType | None = ...,
2032+
float_format: FloatFormatType | None = ...,
20302033
sparsify: _bool | None = ...,
20312034
index_names: _bool = ...,
20322035
justify: _str | None = ...,
20332036
max_rows: int | None = ...,
2034-
min_rows: int | None = ...,
20352037
max_cols: int | None = ...,
20362038
show_dimensions: _bool = ...,
20372039
decimal: _str = ...,
20382040
line_width: int | None = ...,
2041+
min_rows: int | None = ...,
20392042
max_colwidth: int | None = ...,
20402043
encoding: _str | None = ...,
20412044
) -> _str: ...

pandas-stubs/core/generic.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
244244
mode: _str = ...,
245245
encoding: _str | None = ...,
246246
compression: _str | Mapping[_str, _str] = ...,
247-
quoting: int | None = ...,
247+
quoting: Literal[0, 1, 2, 3] | None = ...,
248248
quotechar: _str = ...,
249249
line_terminator: _str | None = ...,
250250
chunksize: int | None = ...,
@@ -268,7 +268,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
268268
mode: _str = ...,
269269
encoding: _str | None = ...,
270270
compression: _str | Mapping[_str, _str] = ...,
271-
quoting: int | None = ...,
271+
quoting: Literal[0, 1, 2, 3] | None = ...,
272272
quotechar: _str = ...,
273273
line_terminator: _str | None = ...,
274274
chunksize: int | None = ...,
@@ -284,7 +284,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
284284
) -> NDFrame: ...
285285
def xs(
286286
self,
287-
key: _str | tuple[_str],
287+
key: Hashable,
288288
axis: SeriesAxisType = ...,
289289
level: Level | None = ...,
290290
drop_level: _bool = ...,

pandas-stubs/core/groupby/groupby.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from pandas.core.base import (
77
from pandas.core.frame import DataFrame
88
from pandas.core.generic import NDFrame
99
from pandas.core.groupby import ops
10-
from pandas.core.groupby.indexing import GroupByIndexingMixin
1110
from pandas.core.indexes.api import Index
1211
from pandas.core.series import Series
1312

@@ -23,7 +22,7 @@ class GroupByPlot(PandasObject):
2322
def __call__(self, *args, **kwargs): ...
2423
def __getattr__(self, name: str): ...
2524

26-
class BaseGroupBy(PandasObject, SelectionMixin[NDFrameT], GroupByIndexingMixin):
25+
class BaseGroupBy(PandasObject, SelectionMixin[NDFrameT]):
2726
level = ...
2827
as_index = ...
2928
keys = ...

pandas-stubs/core/series.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ from pandas._typing import (
6565
Axis,
6666
AxisType,
6767
CompressionOptions,
68-
Dtype,
6968
DtypeNp,
69+
DtypeObj,
7070
FilePathOrBuffer,
7171
FillnaOptions,
7272
GroupByObjectNonScalar,
@@ -220,9 +220,9 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
220220
axis: SeriesAxisType = ...,
221221
) -> Series[S1]: ...
222222
@property
223-
def dtype(self) -> Dtype: ...
223+
def dtype(self) -> DtypeObj: ...
224224
@property
225-
def dtypes(self) -> Dtype: ...
225+
def dtypes(self) -> DtypeObj: ...
226226
@property
227227
def name(self) -> Hashable | None: ...
228228
@name.setter

pandas-stubs/io/clipboards.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def read_clipboard(
7171
decimal: str = ...,
7272
lineterminator: str | None = ...,
7373
quotechar: str = ...,
74-
quoting: int = ...,
74+
quoting: Literal[0, 1, 2, 3] | None = ...,
7575
doublequote: bool = ...,
7676
escapechar: str | None = ...,
7777
comment: str | None = ...,
@@ -137,7 +137,7 @@ def read_clipboard(
137137
decimal: str = ...,
138138
lineterminator: str | None = ...,
139139
quotechar: str = ...,
140-
quoting: int = ...,
140+
quoting: Literal[0, 1, 2, 3] | None = ...,
141141
doublequote: bool = ...,
142142
escapechar: str | None = ...,
143143
comment: str | None = ...,
@@ -203,7 +203,7 @@ def read_clipboard(
203203
decimal: str = ...,
204204
lineterminator: str | None = ...,
205205
quotechar: str = ...,
206-
quoting: int = ...,
206+
quoting: Literal[0, 1, 2, 3] | None = ...,
207207
doublequote: bool = ...,
208208
escapechar: str | None = ...,
209209
comment: str | None = ...,

pandas-stubs/io/common.pyi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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: ...

0 commit comments

Comments
 (0)