Skip to content

TYP: drop #46423

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 7 commits into from
Mar 21, 2022
Merged

TYP: drop #46423

merged 7 commits into from
Mar 21, 2022

Conversation

twoertwein
Copy link
Member

Tested with mypy and pyright:

import pandas as pd

def bool_() -> bool:
    ...

df = pd.DataFrame({"a": []})
ser = pd.Series({"a": 1, "b": 2})

# DataFrame/Series
reveal_type(df.drop(columns="a"))
reveal_type(df.drop(columns="a", inplace=False))
reveal_type(ser.drop(index="a"))
reveal_type(ser.drop(index="a", inplace=False))

# None
reveal_type(df.drop(columns="a", inplace=True))
reveal_type(ser.drop(index="a", inplace=True))

# both
reveal_type(df.drop(columns="a", inplace=bool_()))
reveal_type(ser.drop(index="a", inplace=bool_()))

@@ -297,6 +297,9 @@ def closed(self) -> bool:
else:
TakeIndexer = Any

# Shared by functions such as drop and astype
IgnoreRaise = Literal["ignore", "raise"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added it to a few other functions (there might be more that only accept ignore/raise).

) -> NDFrameT | None:
...

@deprecate_nonkeyword_arguments(version=None, allowed_args=["self", "labels"])
Copy link
Member Author

@twoertwein twoertwein Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deprecation is new. Previously, this deprecation was only in Series/DataFrame.

@twoertwein twoertwein added the Typing type annotations, mypy/pyright type checking label Mar 18, 2022
@twoertwein twoertwein requested a review from Dr-Irv March 18, 2022 22:21
@twoertwein twoertwein mentioned this pull request Mar 19, 2022
@jreback jreback added this to the 1.5 milestone Mar 19, 2022
Copy link
Contributor

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add a reference to the mypy issue you created so we can track it.

@jreback jreback merged commit 96199e7 into pandas-dev:main Mar 21, 2022
@twoertwein twoertwein deleted the drop branch April 1, 2022 01:36
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants