Skip to content

Commit

Permalink
Type args and kwargs parameters in generic pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
paw-lu committed Dec 25, 2023
1 parent d71a30b commit f4807a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 17 additions & 2 deletions pandas-stubs/core/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -40,6 +43,7 @@ from pandas._typing import (
IgnoreRaise,
IndexLabel,
Level,
P,
ReplaceMethod,
SortKind,
StorageOptions,
Expand Down Expand Up @@ -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: ...
Expand Down

0 comments on commit f4807a9

Please sign in to comment.