Skip to content

Commit 8717b4d

Browse files
committed
type generic
1 parent b4c3b56 commit 8717b4d

File tree

3 files changed

+58
-71
lines changed

3 files changed

+58
-71
lines changed

pandas-stubs/core/generic.pyi

Lines changed: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from collections.abc import (
77
Hashable,
88
Iterable,
99
Mapping,
10-
MutableMapping,
1110
Sequence,
1211
)
1312
import datetime as dt
@@ -40,13 +39,16 @@ from pandas._typing import (
4039
ExcelWriterMergeCells,
4140
FilePath,
4241
FileWriteMode,
42+
FloatFormatType,
43+
FormattersType,
4344
Frequency,
4445
HashableT1,
4546
HashableT2,
4647
HDFCompLib,
4748
IgnoreRaise,
4849
IndexLabel,
4950
Level,
51+
NpDtype,
5052
OpenFileErrors,
5153
P,
5254
StorageOptions,
@@ -56,9 +58,11 @@ from pandas._typing import (
5658
TimeGrouperOrigin,
5759
TimestampConvertibleTypes,
5860
WriteBuffer,
61+
WriteExcelBuffer,
5962
np_ndarray,
6063
)
6164

65+
from pandas.io.excel import ExcelWriter
6266
from pandas.io.pytables import HDFStore
6367
from pandas.io.sql import SQLTable
6468

@@ -95,15 +99,17 @@ class NDFrame:
9599
@final
96100
def __round__(self, decimals: int = ...) -> Self: ...
97101
@final
98-
def __contains__(self, key) -> _bool: ...
102+
def __contains__(self, key: Any) -> _bool: ...
99103
@property
100104
def empty(self) -> _bool: ...
101105
__array_priority__: int = ...
102-
def __array__(self, dtype=...) -> np_ndarray: ...
106+
def __array__(
107+
self, dtype: NpDtype | None = None, copy: _bool | None = None
108+
) -> np_ndarray: ...
103109
@final
104110
def to_excel(
105111
self,
106-
excel_writer,
112+
excel_writer: FilePath | WriteExcelBuffer | ExcelWriter,
107113
sheet_name: _str = "Sheet1",
108114
na_rep: _str = "",
109115
float_format: _str | None = ...,
@@ -220,8 +226,8 @@ class NDFrame:
220226
header: _bool | list[_str] = ...,
221227
index: _bool = ...,
222228
na_rep: _str = ...,
223-
formatters=...,
224-
float_format=...,
229+
formatters: FormattersType | None = None,
230+
float_format: FloatFormatType | None = None,
225231
sparsify: _bool | None = ...,
226232
index_names: _bool = ...,
227233
bold_rows: _bool = ...,
@@ -245,8 +251,8 @@ class NDFrame:
245251
header: _bool | list[_str] = ...,
246252
index: _bool = ...,
247253
na_rep: _str = ...,
248-
formatters=...,
249-
float_format=...,
254+
formatters: FormattersType | None = None,
255+
float_format: FloatFormatType | None = None,
250256
sparsify: _bool | None = ...,
251257
index_names: _bool = ...,
252258
bold_rows: _bool = ...,
@@ -312,115 +318,113 @@ class NDFrame:
312318
errors: OpenFileErrors = ...,
313319
storage_options: StorageOptions = ...,
314320
) -> _str: ...
315-
@final
316-
def __delitem__(self, idx: Hashable) -> None: ...
317321
@overload
318322
def drop(
319323
self,
320-
labels=...,
324+
labels: Hashable | Sequence[Hashable] | Index | None = None,
321325
*,
322-
axis=...,
326+
axis: Axis = 0,
323327
index: None,
324-
columns=...,
325-
level=...,
326-
inplace=...,
327-
errors=...,
328+
columns: Hashable | Iterable[Hashable] | None = None,
329+
level: Level | None = None,
330+
inplace: Literal[False] = False,
331+
errors: IgnoreRaise = "raise",
328332
) -> Never: ...
329333
@overload
330334
def drop(
331335
self,
332-
labels=...,
336+
labels: Hashable | Sequence[Hashable] | Index | None = None,
333337
*,
334-
axis=...,
335-
index=...,
338+
axis: Axis = 0,
339+
index: Hashable | Sequence[Hashable] | Index | None = None,
336340
columns: None,
337-
level=...,
338-
inplace=...,
339-
errors=...,
341+
level: Level | None = None,
342+
inplace: Literal[False] = False,
343+
errors: IgnoreRaise = "raise",
340344
) -> Never: ...
341345
@overload
342346
def drop(
343347
self,
344348
labels: None,
345349
*,
346-
axis=...,
347-
index=...,
348-
columns=...,
349-
level=...,
350-
inplace=...,
351-
errors=...,
350+
axis: Axis = 0,
351+
index: Hashable | Sequence[Hashable] | Index | None = None,
352+
columns: Hashable | Iterable[Hashable] | None = None,
353+
level: Level | None = None,
354+
inplace: Literal[False] = False,
355+
errors: IgnoreRaise = "raise",
352356
) -> Never: ...
353357
@overload
354358
def drop(
355359
self,
356360
labels: None = None,
357361
*,
358-
axis: Axis = ...,
359-
index: Hashable | Sequence[Hashable] | Index = ...,
362+
axis: Axis = 0,
363+
index: Hashable | Sequence[Hashable] | Index | None = None,
360364
columns: Hashable | Iterable[Hashable],
361-
level: Level | None = ...,
365+
level: Level | None = None,
362366
inplace: Literal[True],
363-
errors: IgnoreRaise = ...,
367+
errors: IgnoreRaise = "raise",
364368
) -> None: ...
365369
@overload
366370
def drop(
367371
self,
368372
labels: None = None,
369373
*,
370-
axis: Axis = ...,
374+
axis: Axis = 0,
371375
index: Hashable | Sequence[Hashable] | Index,
372-
columns: Hashable | Iterable[Hashable] = ...,
373-
level: Level | None = ...,
376+
columns: Hashable | Iterable[Hashable] | None = None,
377+
level: Level | None = None,
374378
inplace: Literal[True],
375-
errors: IgnoreRaise = ...,
379+
errors: IgnoreRaise = "raise",
376380
) -> None: ...
377381
@overload
378382
def drop(
379383
self,
380384
labels: Hashable | Sequence[Hashable] | Index,
381385
*,
382-
axis: Axis = ...,
386+
axis: Axis = 0,
383387
index: None = None,
384388
columns: None = None,
385-
level: Level | None = ...,
389+
level: Level | None = None,
386390
inplace: Literal[True],
387-
errors: IgnoreRaise = ...,
391+
errors: IgnoreRaise = "raise",
388392
) -> None: ...
389393
@overload
390394
def drop(
391395
self,
392396
labels: None = None,
393397
*,
394-
axis: Axis = ...,
395-
index: Hashable | Sequence[Hashable] | Index = ...,
398+
axis: Axis = 0,
399+
index: Hashable | Sequence[Hashable] | Index | None = None,
396400
columns: Hashable | Iterable[Hashable],
397-
level: Level | None = ...,
401+
level: Level | None = None,
398402
inplace: Literal[False] = False,
399-
errors: IgnoreRaise = ...,
403+
errors: IgnoreRaise = "raise",
400404
) -> Self: ...
401405
@overload
402406
def drop(
403407
self,
404408
labels: None = None,
405409
*,
406-
axis: Axis = ...,
410+
axis: Axis = 0,
407411
index: Hashable | Sequence[Hashable] | Index,
408-
columns: Hashable | Iterable[Hashable] = ...,
409-
level: Level | None = ...,
412+
columns: Hashable | Iterable[Hashable] | None = None,
413+
level: Level | None = None,
410414
inplace: Literal[False] = False,
411-
errors: IgnoreRaise = ...,
415+
errors: IgnoreRaise = "raise",
412416
) -> Self: ...
413417
@overload
414418
def drop(
415419
self,
416420
labels: Hashable | Sequence[Hashable] | Index,
417421
*,
418-
axis: Axis = ...,
422+
axis: Axis = 0,
419423
index: None = None,
420424
columns: None = None,
421-
level: Level | None = ...,
425+
level: Level | None = None,
422426
inplace: Literal[False] = False,
423-
errors: IgnoreRaise = ...,
427+
errors: IgnoreRaise = "raise",
424428
) -> Self: ...
425429
@overload
426430
def pipe(
@@ -437,14 +441,6 @@ class NDFrame:
437441
**kwargs: Any,
438442
) -> T: ...
439443
@final
440-
def __finalize__(self, other, method=..., **kwargs: Any) -> Self: ...
441-
@final
442-
def __setattr__(self, name: _str, value) -> None: ...
443-
@final
444-
def __copy__(self, deep: _bool = ...) -> Self: ...
445-
@final
446-
def __deepcopy__(self, memo: MutableMapping[int, Any] | None = None) -> Self: ...
447-
@final
448444
def convert_dtypes(
449445
self,
450446
infer_objects: _bool = True,

pandas-stubs/core/series.pyi

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ from pandas._typing import (
188188
ListLikeU,
189189
MaskType,
190190
NaPosition,
191+
NpDtype,
191192
NsmallestNlargestKeep,
192193
NumpyStrDtypeArg,
193194
ObjectDtypeArg,
@@ -562,15 +563,9 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
562563
def __array_ufunc__(
563564
self, ufunc: Callable[..., Any], method: _str, *inputs: Any, **kwargs: Any
564565
) -> Any: ...
565-
if sys.version_info >= (3, 11):
566-
def __array__(
567-
self, dtype: _str | np.dtype = ..., copy: bool | None = ...
568-
) -> np_1darray: ...
569-
else:
570-
def __array__(
571-
self, dtype: _str | np.dtype[Any] = ..., copy: bool | None = ...
572-
) -> np_1darray: ...
573-
566+
def __array__(
567+
self, dtype: NpDtype | None = None, copy: bool | None = None
568+
) -> np_1darray: ...
574569
@final
575570
def __getattr__(self, name: _str) -> S1: ...
576571

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ ignore = [
213213
# TODO: remove when window is fully typed
214214
"ANN001", "ANN201", "ANN204", "ANN206",
215215
]
216-
"*generic.pyi" = [
217-
# TODO: remove when generic.pyi is fully typed
218-
"ANN001", "ANN201", "ANN204", "ANN206",
219-
]
220216
"*array*" = [
221217
# TODO: remove when array is fully typed
222218
"ANN001", "ANN201", "ANN204", "ANN206",

0 commit comments

Comments
 (0)