-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TYP: Overload series/ffill and bfill #41152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6469,15 +6469,45 @@ def fillna( | |
else: | ||
return result.__finalize__(self, method="fillna") | ||
|
||
@overload | ||
def ffill( | ||
self: FrameOrSeries, | ||
axis: None | str | int = ..., | ||
inplace: Literal[False] = ..., | ||
limit: None | int = ..., | ||
downcast: None | str | dict = ..., | ||
) -> FrameOrSeries: | ||
... | ||
|
||
@overload | ||
def ffill( | ||
self: FrameOrSeries, | ||
axis: None | str | int = ..., | ||
inplace: Literal[True] = ..., | ||
limit: None | int = ..., | ||
downcast: None | str | dict = ..., | ||
) -> None: | ||
... | ||
|
||
@overload | ||
def ffill( | ||
self: FrameOrSeries, | ||
axis: None | str | int = ..., | ||
inplace: bool_t = ..., | ||
limit: None | int = ..., | ||
downcast: None | str | dict = ..., | ||
) -> FrameOrSeries | None: | ||
... | ||
|
||
@final | ||
@doc(klass=_shared_doc_kwargs["klass"]) | ||
def ffill( | ||
self: FrameOrSeries, | ||
axis=None, | ||
axis: None | str | int = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. axis has it's own type alias, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
inplace: bool_t = False, | ||
limit=None, | ||
downcast=None, | ||
) -> FrameOrSeries | None: | ||
limit: None | int = None, | ||
downcast: None | str | dict = None, | ||
): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should work to keep the return types here, then the function body's return type will be fixed (admittedly this needs fixing in my blog post, will do that now) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
""" | ||
Synonym for :meth:`DataFrame.fillna` with ``method='ffill'``. | ||
|
||
|
@@ -6492,15 +6522,45 @@ def ffill( | |
|
||
pad = ffill | ||
|
||
@overload | ||
def bfill( | ||
self: FrameOrSeries, | ||
axis: None | str | int = ..., | ||
inplace: Literal[False] = ..., | ||
limit: None | int = ..., | ||
downcast: None | str | dict = ..., | ||
) -> FrameOrSeries: | ||
... | ||
|
||
@overload | ||
def bfill( | ||
self: FrameOrSeries, | ||
axis: None | str | int = ..., | ||
inplace: Literal[True] = ..., | ||
limit: None | int = ..., | ||
downcast: None | str | dict = ..., | ||
) -> None: | ||
... | ||
|
||
@overload | ||
def bfill( | ||
self: FrameOrSeries, | ||
axis: None | str | int = ..., | ||
inplace: bool_t = ..., | ||
limit: None | int = ..., | ||
downcast: None | str | dict = ..., | ||
) -> FrameOrSeries | None: | ||
... | ||
|
||
@final | ||
@doc(klass=_shared_doc_kwargs["klass"]) | ||
def bfill( | ||
self: FrameOrSeries, | ||
axis=None, | ||
axis: None | str | int = None, | ||
inplace: bool_t = False, | ||
limit=None, | ||
downcast=None, | ||
) -> FrameOrSeries | None: | ||
limit: None | int = None, | ||
downcast: None | str | dict = None, | ||
): | ||
""" | ||
Synonym for :meth:`DataFrame.fillna` with ``method='bfill'``. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one doesn't need
=...
- else, if you call.ffill()
, mypy won't know which overload to matchThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there also needs to be an extra overload for when
axis
isn't passed:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done