diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index 5ab88069..272b9eec 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -28,7 +28,10 @@ from pandas.core.generic import NDFrame from pandas.core.groupby.grouper import Grouper from pandas.core.indexes.base import Index from pandas.core.series import Series -from typing_extensions import TypeAlias +from typing_extensions import ( + ParamSpec, + TypeAlias, +) from pandas._libs.interval import Interval from pandas._libs.tslibs import ( @@ -446,6 +449,7 @@ JSONSerializable: TypeAlias = PythonScalar | list | dict Axes: TypeAlias = AnyArrayLike | list | dict | range | tuple Renamer: TypeAlias = Mapping[Any, Label] | Callable[[Any], Label] T = TypeVar("T") +P = ParamSpec("P") FuncType: TypeAlias = Callable[..., Any] F = TypeVar("F", bound=FuncType) HashableT = TypeVar("HashableT", bound=Hashable) diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index 1d8b3aa4..e491b918 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -19,7 +19,10 @@ from pandas import Index import pandas.core.indexing as indexing from pandas.core.series import Series import sqlalchemy.engine -from typing_extensions import Self +from typing_extensions import ( + Concatenate, + Self, +) from pandas._typing import ( S1, @@ -40,6 +43,7 @@ from pandas._typing import ( IgnoreRaise, IndexLabel, Level, + P, ReplaceMethod, SortKind, StorageOptions, @@ -352,8 +356,19 @@ class NDFrame(indexing.IndexingMixin): ) -> Self: ... def head(self, n: int = ...) -> Self: ... def tail(self, n: int = ...) -> Self: ... + @overload + def pipe( + self, + func: Callable[Concatenate[Self, P], T], + *args: P.args, + **kwargs: P.kwargs, + ) -> T: ... + @overload def pipe( - self, func: Callable[..., T] | tuple[Callable[..., T], str], *args, **kwargs + self, + func: tuple[Callable[..., T], str], + *args: Any, + **kwargs: Any, ) -> T: ... def __finalize__(self, other, method=..., **kwargs) -> Self: ... def __setattr__(self, name: _str, value) -> None: ...