diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index 2f09f6da8..8a239c656 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -7,11 +7,11 @@ from collections.abc import ( Hashable, Iterable, Mapping, - MutableMapping, Sequence, ) import datetime as dt import sqlite3 +import sys from typing import ( Any, ClassVar, @@ -21,6 +21,7 @@ from typing import ( overload, ) +import numpy as np from pandas import Index from pandas.core.resample import DatetimeIndexResampler from pandas.core.series import Series @@ -40,6 +41,8 @@ from pandas._typing import ( ExcelWriterMergeCells, FilePath, FileWriteMode, + FloatFormatType, + FormattersType, Frequency, HashableT1, HashableT2, @@ -47,6 +50,7 @@ from pandas._typing import ( IgnoreRaise, IndexLabel, Level, + ListLike, OpenFileErrors, P, StorageOptions, @@ -56,9 +60,11 @@ from pandas._typing import ( TimeGrouperOrigin, TimestampConvertibleTypes, WriteBuffer, - np_ndarray, + WriteExcelBuffer, + np_1darray, ) +from pandas.io.excel import ExcelWriter from pandas.io.pytables import HDFStore from pandas.io.sql import SQLTable @@ -95,15 +101,23 @@ class NDFrame: @final def __round__(self, decimals: int = ...) -> Self: ... @final - def __contains__(self, key) -> _bool: ... + def __contains__(self, key: Any) -> _bool: ... @property def empty(self) -> _bool: ... __array_priority__: int = ... - def __array__(self, dtype=...) -> np_ndarray: ... + if sys.version_info >= (3, 11): + def __array__( + self, dtype: _str | np.dtype = ..., copy: _bool | None = ... + ) -> np_1darray: ... + else: + def __array__( + self, dtype: _str | np.dtype[Any] = ..., copy: _bool | None = ... + ) -> np_1darray: ... + @final def to_excel( self, - excel_writer, + excel_writer: FilePath | WriteExcelBuffer | ExcelWriter, sheet_name: _str = "Sheet1", na_rep: _str = "", float_format: _str | None = ..., @@ -220,8 +234,8 @@ class NDFrame: header: _bool | list[_str] = ..., index: _bool = ..., na_rep: _str = ..., - formatters=..., - float_format=..., + formatters: FormattersType | None = None, + float_format: FloatFormatType | None = None, sparsify: _bool | None = ..., index_names: _bool = ..., bold_rows: _bool = ..., @@ -245,8 +259,8 @@ class NDFrame: header: _bool | list[_str] = ..., index: _bool = ..., na_rep: _str = ..., - formatters=..., - float_format=..., + formatters: FormattersType | None = None, + float_format: FloatFormatType | None = None, sparsify: _bool | None = ..., index_names: _bool = ..., bold_rows: _bool = ..., @@ -312,115 +326,113 @@ class NDFrame: errors: OpenFileErrors = ..., storage_options: StorageOptions = ..., ) -> _str: ... - @final - def __delitem__(self, idx: Hashable) -> None: ... @overload def drop( self, - labels=..., + labels: Hashable | ListLike = None, *, - axis=..., + axis: Axis = 0, index: None, - columns=..., - level=..., - inplace=..., - errors=..., + columns: Hashable | Iterable[Hashable] = None, + level: Level | None = None, + inplace: Literal[False] = False, + errors: IgnoreRaise = "raise", ) -> Never: ... @overload def drop( self, - labels=..., + labels: Hashable | ListLike = None, *, - axis=..., - index=..., + axis: Axis = 0, + index: Hashable | Sequence[Hashable] | Index = None, columns: None, - level=..., - inplace=..., - errors=..., + level: Level | None = None, + inplace: Literal[False] = False, + errors: IgnoreRaise = "raise", ) -> Never: ... @overload def drop( self, labels: None, *, - axis=..., - index=..., - columns=..., - level=..., - inplace=..., - errors=..., + axis: Axis = 0, + index: Hashable | Sequence[Hashable] | Index = None, + columns: Hashable | Iterable[Hashable] = None, + level: Level | None = None, + inplace: Literal[False] = False, + errors: IgnoreRaise = "raise", ) -> Never: ... @overload def drop( self, labels: None = None, *, - axis: Axis = ..., - index: Hashable | Sequence[Hashable] | Index = ..., + axis: Axis = 0, + index: Hashable | Sequence[Hashable] | Index = None, columns: Hashable | Iterable[Hashable], - level: Level | None = ..., + level: Level | None = None, inplace: Literal[True], - errors: IgnoreRaise = ..., + errors: IgnoreRaise = "raise", ) -> None: ... @overload def drop( self, labels: None = None, *, - axis: Axis = ..., + axis: Axis = 0, index: Hashable | Sequence[Hashable] | Index, - columns: Hashable | Iterable[Hashable] = ..., - level: Level | None = ..., + columns: Hashable | Iterable[Hashable] = None, + level: Level | None = None, inplace: Literal[True], - errors: IgnoreRaise = ..., + errors: IgnoreRaise = "raise", ) -> None: ... @overload def drop( self, - labels: Hashable | Sequence[Hashable] | Index, + labels: Hashable | ListLike, *, - axis: Axis = ..., + axis: Axis = 0, index: None = None, columns: None = None, - level: Level | None = ..., + level: Level | None = None, inplace: Literal[True], - errors: IgnoreRaise = ..., + errors: IgnoreRaise = "raise", ) -> None: ... @overload def drop( self, labels: None = None, *, - axis: Axis = ..., - index: Hashable | Sequence[Hashable] | Index = ..., + axis: Axis = 0, + index: Hashable | Sequence[Hashable] | Index = None, columns: Hashable | Iterable[Hashable], - level: Level | None = ..., + level: Level | None = None, inplace: Literal[False] = False, - errors: IgnoreRaise = ..., + errors: IgnoreRaise = "raise", ) -> Self: ... @overload def drop( self, labels: None = None, *, - axis: Axis = ..., + axis: Axis = 0, index: Hashable | Sequence[Hashable] | Index, - columns: Hashable | Iterable[Hashable] = ..., - level: Level | None = ..., + columns: Hashable | Iterable[Hashable] = None, + level: Level | None = None, inplace: Literal[False] = False, - errors: IgnoreRaise = ..., + errors: IgnoreRaise = "raise", ) -> Self: ... @overload def drop( self, - labels: Hashable | Sequence[Hashable] | Index, + labels: Hashable | ListLike, *, - axis: Axis = ..., + axis: Axis = 0, index: None = None, columns: None = None, - level: Level | None = ..., + level: Level | None = None, inplace: Literal[False] = False, - errors: IgnoreRaise = ..., + errors: IgnoreRaise = "raise", ) -> Self: ... @overload def pipe( @@ -437,14 +449,6 @@ class NDFrame: **kwargs: Any, ) -> T: ... @final - def __finalize__(self, other, method=..., **kwargs: Any) -> Self: ... - @final - def __setattr__(self, name: _str, value) -> None: ... - @final - def __copy__(self, deep: _bool = ...) -> Self: ... - @final - def __deepcopy__(self, memo: MutableMapping[int, Any] | None = None) -> Self: ... - @final def convert_dtypes( self, infer_objects: _bool = True, diff --git a/pyproject.toml b/pyproject.toml index 540bb7117..278f68233 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -209,10 +209,6 @@ ignore = [ # TODO: remove when computations are fully typed "ANN001", "ANN201", "ANN204", "ANN206", ] -"*generic.pyi" = [ - # TODO: remove when generic.pyi is fully typed - "ANN001", "ANN201", "ANN204", "ANN206", -] "*array*" = [ # TODO: remove when array is fully typed "ANN001", "ANN201", "ANN204", "ANN206",