Skip to content

Commit 90babd2

Browse files
committed
Type args and kwargs parameters in generic pipe
1 parent cce1b18 commit 90babd2

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

pandas-stubs/_typing.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ from pandas.core.generic import NDFrame
2828
from pandas.core.groupby.grouper import Grouper
2929
from pandas.core.indexes.base import Index
3030
from pandas.core.series import Series
31-
from typing_extensions import TypeAlias
31+
from typing_extensions import (
32+
ParamSpec,
33+
TypeAlias,
34+
)
3235

3336
from pandas._libs.interval import Interval
3437
from pandas._libs.tslibs import (
@@ -447,6 +450,7 @@ JSONSerializable: TypeAlias = PythonScalar | list | dict
447450
Axes: TypeAlias = AnyArrayLike | list | dict | range | tuple
448451
Renamer: TypeAlias = Mapping[Any, Label] | Callable[[Any], Label]
449452
T = TypeVar("T")
453+
P = ParamSpec("P")
450454
FuncType: TypeAlias = Callable[..., Any]
451455
F = TypeVar("F", bound=FuncType)
452456
HashableT = TypeVar("HashableT", bound=Hashable)

pandas-stubs/core/generic.pyi

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ from pandas import Index
1919
import pandas.core.indexing as indexing
2020
from pandas.core.series import Series
2121
import sqlalchemy.engine
22-
from typing_extensions import Self
22+
from typing_extensions import (
23+
Concatenate,
24+
Self,
25+
)
2326

2427
from pandas._typing import (
2528
S1,
@@ -40,6 +43,7 @@ from pandas._typing import (
4043
IgnoreRaise,
4144
IndexLabel,
4245
Level,
46+
P,
4347
ReplaceMethod,
4448
SortKind,
4549
StorageOptions,
@@ -352,8 +356,19 @@ class NDFrame(indexing.IndexingMixin):
352356
) -> Self: ...
353357
def head(self, n: int = ...) -> Self: ...
354358
def tail(self, n: int = ...) -> Self: ...
359+
@overload
360+
def pipe(
361+
self,
362+
func: Callable[Concatenate[Self, P], T],
363+
*args: P.args,
364+
**kwargs: P.kwargs,
365+
) -> T: ...
366+
@overload
355367
def pipe(
356-
self, func: Callable[..., T] | tuple[Callable[..., T], str], *args, **kwargs
368+
self,
369+
func: tuple[Callable[..., T], str],
370+
*args: Any,
371+
**kwargs: Any,
357372
) -> T: ...
358373
def __finalize__(self, other, method=..., **kwargs) -> Self: ...
359374
def __setattr__(self, name: _str, value) -> None: ...

0 commit comments

Comments
 (0)