Skip to content

TYP fixup overloads for reset_index #40200

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

Merged
merged 6 commits into from
Mar 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixup overloads for reset_index
  • Loading branch information
MarcoGorelli committed Mar 3, 2021
commit 53da46b609fcdf94646d82f7d5f1a6ba16d6be6b
42 changes: 36 additions & 6 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5122,9 +5122,7 @@ def set_index(
return frame

@overload
# https://github.com/python/mypy/issues/6580
# Overloaded function signatures 1 and 2 overlap with incompatible return types
def reset_index( # type: ignore[misc]
def reset_index(
self,
level: Optional[Union[Hashable, Sequence[Hashable]]] = ...,
drop: bool = ...,
Expand All @@ -5137,9 +5135,41 @@ def reset_index( # type: ignore[misc]
@overload
def reset_index(
self,
level: Optional[Union[Hashable, Sequence[Hashable]]] = ...,
drop: bool = ...,
inplace: Literal[True] = ...,
level: Optional[Union[Hashable, Sequence[Hashable]]],
drop: bool,
inplace: Literal[True],
col_level: Hashable = ...,
col_fill: Hashable = ...,
) -> None:
...

@overload
def reset_index(
self,
*,
drop: bool,
inplace: Literal[True],
col_level: Hashable = ...,
col_fill: Hashable = ...,
) -> None:
...

@overload
def reset_index(
self,
*,
level: Optional[Union[Hashable, Sequence[Hashable]]],
inplace: Literal[True],
col_level: Hashable = ...,
col_fill: Hashable = ...,
) -> None:
...

@overload
def reset_index(
self,
*,
inplace: Literal[True],
col_level: Hashable = ...,
col_fill: Hashable = ...,
) -> None:
Expand Down