Skip to content

Commit 19a230b

Browse files
committed
Type args and kwargs parameters in generic pipe
1 parent 385ff55 commit 19a230b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-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 (
@@ -446,6 +449,7 @@ JSONSerializable: TypeAlias = PythonScalar | list | dict
446449
Axes: TypeAlias = AnyArrayLike | list | dict | range | tuple
447450
Renamer: TypeAlias = Mapping[Any, Label] | Callable[[Any], Label]
448451
T = TypeVar("T")
452+
P = ParamSpec("P")
449453
FuncType: TypeAlias = Callable[..., Any]
450454
F = TypeVar("F", bound=FuncType)
451455
HashableT = TypeVar("HashableT", bound=Hashable)

pandas-stubs/core/generic.pyi

Lines changed: 9 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,
@@ -353,7 +357,10 @@ class NDFrame(indexing.IndexingMixin):
353357
def head(self, n: int = ...) -> Self: ...
354358
def tail(self, n: int = ...) -> Self: ...
355359
def pipe(
356-
self, func: Callable[..., T] | tuple[Callable[..., T], str], *args, **kwargs
360+
self,
361+
func: Callable[Concatenate[Self, P], T] | tuple[Callable[..., T], str],
362+
*args: P.args,
363+
**kwargs: P.kwargs,
357364
) -> T: ...
358365
def __finalize__(self, other, method=..., **kwargs) -> Self: ...
359366
def __setattr__(self, name: _str, value) -> None: ...

0 commit comments

Comments
 (0)