From e9cf3651a51aef35eabb78bfdd8fe403d97a9b57 Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Tue, 28 Oct 2025 17:52:45 +0100 Subject: [PATCH 1/3] plotting and io --- pandas-stubs/core/generic.pyi | 2 +- pandas-stubs/core/indexes/base.pyi | 2 +- pandas-stubs/io/formats/style.pyi | 2 +- pandas-stubs/io/pytables.pyi | 5 +++-- pandas-stubs/io/sas/sasreader.pyi | 8 +++++++- pandas-stubs/io/sql.pyi | 13 +++++++------ pandas-stubs/plotting/_core.pyi | 4 ++-- pyproject.toml | 8 -------- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index 8cc612667..8d3baa2aa 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -442,7 +442,7 @@ class NDFrame(indexing.IndexingMixin): @final def __copy__(self, deep: _bool = ...) -> Self: ... @final - def __deepcopy__(self, memo=...) -> Self: ... + def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self: ... @final def convert_dtypes( self, diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index 40129638a..47d3a75c9 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -343,7 +343,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): @final def __copy__(self, **kwargs: Any): ... @final - def __deepcopy__(self, memo=...): ... + def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self: ... def format( self, name: bool = ..., formatter: Callable | None = ..., na_rep: _str = ... ) -> list[_str]: ... diff --git a/pandas-stubs/io/formats/style.pyi b/pandas-stubs/io/formats/style.pyi index 7609cb4a3..c18d1e326 100644 --- a/pandas-stubs/io/formats/style.pyi +++ b/pandas-stubs/io/formats/style.pyi @@ -224,7 +224,7 @@ class Styler(StylerRenderer): ) -> str: ... def set_td_classes(self, classes: DataFrame) -> Styler: ... def __copy__(self) -> Styler: ... - def __deepcopy__(self, memo) -> Styler: ... + def __deepcopy__(self, memo: dict[int, Any] | None) -> Styler: ... def clear(self) -> None: ... @overload def apply( diff --git a/pandas-stubs/io/pytables.pyi b/pandas-stubs/io/pytables.pyi index 006620f78..a4e75c05d 100644 --- a/pandas-stubs/io/pytables.pyi +++ b/pandas-stubs/io/pytables.pyi @@ -19,6 +19,7 @@ from pandas.core.generic import NDFrame from typing_extensions import Self from pandas._typing import ( + BaseBuffer, FilePath, HashableT, HashableT1, @@ -101,7 +102,7 @@ def read_hdf( class HDFStore: def __init__( self, - path, + path: FilePath | BaseBuffer, mode: Literal["a", "w", "r", "r+"] = ..., complevel: int | None = ..., complib: HDFCompLib | None = ..., @@ -122,7 +123,7 @@ class HDFStore: exc_value: BaseException | None, traceback: TracebackType | None, ) -> None: ... - def keys(self, include="pandas") -> list[str]: ... + def keys(self, include: Literal["pandas", "native"] = "pandas") -> list[str]: ... def __iter__(self) -> Iterator[str]: ... def close(self) -> None: ... @property diff --git a/pandas-stubs/io/sas/sasreader.pyi b/pandas-stubs/io/sas/sasreader.pyi index 7865aaa64..9af416bc3 100644 --- a/pandas-stubs/io/sas/sasreader.pyi +++ b/pandas-stubs/io/sas/sasreader.pyi @@ -3,6 +3,7 @@ from abc import ( abstractmethod, ) from collections.abc import Hashable +from types import TracebackType from typing import ( Literal, overload, @@ -26,7 +27,12 @@ class ReaderBase(metaclass=ABCMeta): @abstractmethod def close(self) -> None: ... def __enter__(self) -> Self: ... - def __exit__(self, exc_type, exc_value, traceback) -> None: ... + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, + ) -> None: ... @overload def read_sas( diff --git a/pandas-stubs/io/sql.pyi b/pandas-stubs/io/sql.pyi index 5dadb15c7..1ec25beb7 100644 --- a/pandas-stubs/io/sql.pyi +++ b/pandas-stubs/io/sql.pyi @@ -22,6 +22,7 @@ from pandas._typing import ( DtypeArg, DtypeBackend, Scalar, + SequenceNotStr, npt, ) @@ -147,12 +148,12 @@ class PandasSQL: self, frame: DataFrame, name: str, - if_exists: Literal["fail", "replace", "append"] = ..., - index: bool = ..., - index_label=..., - schema: str | None = ..., - chunksize=..., - dtype: DtypeArg | None = ..., + if_exists: Literal["fail", "replace", "append"] = "fail", + index: bool = True, + index_label: str | SequenceNotStr[str] | None = None, + schema: str | None = None, + chunksize: int | None = None, + dtype: DtypeArg | None = None, method: ( Literal["multi"] | Callable[[SQLTable, Any, list[str], Iterable], int | None] diff --git a/pandas-stubs/plotting/_core.pyi b/pandas-stubs/plotting/_core.pyi index 87201cee1..1b610d958 100644 --- a/pandas-stubs/plotting/_core.pyi +++ b/pandas-stubs/plotting/_core.pyi @@ -17,8 +17,8 @@ from matplotlib.colors import Colormap from matplotlib.lines import Line2D import numpy as np import pandas as pd -from pandas import Series from pandas.core.frame import DataFrame +from pandas.core.series import Series from scipy.stats import gaussian_kde from pandas._typing import ( @@ -85,7 +85,7 @@ def boxplot( ) -> _BoxPlotT: ... class PlotAccessor: - def __init__(self, data) -> None: ... + def __init__(self, data: Series | DataFrame) -> None: ... @overload def __call__( self, diff --git a/pyproject.toml b/pyproject.toml index 91591a5e2..25a00e2ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -228,14 +228,6 @@ ignore = [ # TODO: remove when computations are fully typed "ANN001", "ANN201", "ANN204", "ANN206", ] -"*plotting*" = [ - # TODO: remove when plottings are fully typed - "ANN001", "ANN201", "ANN204", "ANN206", -] -"*io*" = [ - # TODO: remove when io is fully typed - "ANN001", "ANN201", "ANN204", "ANN206", -] "*window*" = [ # TODO: remove when window is fully typed "ANN001", "ANN201", "ANN204", "ANN206", From 4baeec5f5d65d3e406973bed4da0872b1dd5f2cd Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Wed, 29 Oct 2025 13:49:44 +0100 Subject: [PATCH 2/3] https://github.com/pandas-dev/pandas-stubs/pull/1454/files#r2472754113 --- pandas-stubs/core/generic.pyi | 11 ++++++----- pandas-stubs/io/sql.pyi | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index 8d3baa2aa..1bbdcf137 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -162,12 +162,13 @@ class NDFrame(indexing.IndexingMixin): self, name: _str, con: str | sqlalchemy.engine.Connectable | sqlite3.Connection, - schema: _str | None = ..., - if_exists: Literal["fail", "replace", "append"] = "fail", + *, + schema: _str | None = None, + if_exists: Literal["fail", "replace", "append", "delete_rows"] = "fail", index: _bool = True, index_label: IndexLabel = None, - chunksize: int | None = ..., - dtype: DtypeArg | None = ..., + chunksize: int | None = None, + dtype: DtypeArg | None = None, method: ( Literal["multi"] | Callable[ @@ -175,7 +176,7 @@ class NDFrame(indexing.IndexingMixin): int | None, ] | None - ) = ..., + ) = None, ) -> int | None: ... @final def to_pickle( diff --git a/pandas-stubs/io/sql.pyi b/pandas-stubs/io/sql.pyi index 1ec25beb7..a6b9629f8 100644 --- a/pandas-stubs/io/sql.pyi +++ b/pandas-stubs/io/sql.pyi @@ -148,7 +148,7 @@ class PandasSQL: self, frame: DataFrame, name: str, - if_exists: Literal["fail", "replace", "append"] = "fail", + if_exists: Literal["fail", "replace", "append", "delete_rows"] = "fail", index: bool = True, index_label: str | SequenceNotStr[str] | None = None, schema: str | None = None, @@ -158,9 +158,9 @@ class PandasSQL: Literal["multi"] | Callable[[SQLTable, Any, list[str], Iterable], int | None] | None - ) = ..., - engine: str = ..., - **engine_kwargs: dict[str, Any] | None, + ) = None, + engine: str = "auto", + **engine_kwargs: Any, ) -> int | None: ... class SQLTable: @@ -170,7 +170,7 @@ class SQLTable: frame: DataFrame | None index: list[str] schema: str - if_exists: Literal["fail", "replace", "append"] + if_exists: Literal["fail", "replace", "append", "delete_rows"] keys: list[str] dtype: DtypeArg | None table: Any # sqlalchemy.Table @@ -178,14 +178,14 @@ class SQLTable: self, name: str, pandas_sql_engine: PandasSQL, - frame: DataFrame | None = ..., - index: bool | str | list[str] | None = ..., - if_exists: Literal["fail", "replace", "append"] = ..., - prefix: str = ..., - index_label: str | list[str] | None = ..., - schema: str | None = ..., - keys: str | list[str] | None = ..., - dtype: DtypeArg | None = ..., + frame: DataFrame | None = None, + index: bool | str | list[str] | None = True, + if_exists: Literal["fail", "replace", "append", "delete_rows"] = "fail", + prefix: str = "pandas", + index_label: str | list[str] | None = None, + schema: str | None = None, + keys: str | list[str] | None = None, + dtype: DtypeArg | None = None, ) -> None: ... def exists(self) -> bool: ... def sql_schema(self) -> str: ... From bd6ec88128e6c6cbade1f9da668f04514288bd5a Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Wed, 29 Oct 2025 17:54:40 +0100 Subject: [PATCH 3/3] https://github.com/pandas-dev/pandas-stubs/pull/1454#pullrequestreview-3394753519 --- pandas-stubs/core/generic.pyi | 3 ++- pandas-stubs/core/indexes/base.pyi | 3 ++- pandas-stubs/io/formats/style.pyi | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index 1bbdcf137..d93c97ef2 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -7,6 +7,7 @@ from collections.abc import ( Hashable, Iterable, Mapping, + MutableMapping, Sequence, ) import datetime as dt @@ -443,7 +444,7 @@ class NDFrame(indexing.IndexingMixin): @final def __copy__(self, deep: _bool = ...) -> Self: ... @final - def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self: ... + def __deepcopy__(self, memo: MutableMapping[int, Any] | None = None) -> Self: ... @final def convert_dtypes( self, diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index 788506926..c4bf83138 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -3,6 +3,7 @@ from collections.abc import ( Callable, Hashable, Iterable, + MutableMapping, Sequence, ) from datetime import ( @@ -346,7 +347,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]): @final def __copy__(self, **kwargs: Any): ... @final - def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self: ... + def __deepcopy__(self, memo: MutableMapping[int, Any] | None = None) -> Self: ... def format( self, name: bool = ..., formatter: Callable | None = ..., na_rep: _str = ... ) -> list[_str]: ... diff --git a/pandas-stubs/io/formats/style.pyi b/pandas-stubs/io/formats/style.pyi index c18d1e326..a690957d4 100644 --- a/pandas-stubs/io/formats/style.pyi +++ b/pandas-stubs/io/formats/style.pyi @@ -1,5 +1,6 @@ from collections.abc import ( Callable, + MutableMapping, Sequence, ) from typing import ( @@ -224,7 +225,7 @@ class Styler(StylerRenderer): ) -> str: ... def set_td_classes(self, classes: DataFrame) -> Styler: ... def __copy__(self) -> Styler: ... - def __deepcopy__(self, memo: dict[int, Any] | None) -> Styler: ... + def __deepcopy__(self, memo: MutableMapping[int, Any] | None) -> Styler: ... def clear(self) -> None: ... @overload def apply(