Skip to content
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

GH1043 Update _typing.pyi: add "cross" option to JoinHow #1044

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

brzegorzTesco
Copy link

I haven't added tests since JoinHow doesn't seem to be tested in any case. Should I add some? Merge tests unimpacted.

@brzegorzTesco brzegorzTesco changed the title Update _typing.pyi: add "cross" option to JoinHow GH1043 Update _typing.pyi: add "cross" option to JoinHow Nov 21, 2024
Comment on lines 732 to 733
JoinHow: TypeAlias = Literal["left", "right", "outer", "inner", "cross"]
MergeHow: TypeAlias = JoinHow
Copy link
Collaborator

Choose a reason for hiding this comment

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

This fix is not correct, because JoinHow is used as the type of the join argument in the align() method.

The right fix is to change the typing of DataFrame.join() to use the existing MergeHow type.

You would then add a test like your example that shows that "cross" is accepted as a value for the how argument of DataFrame.join()

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the quick feedback, I've done as you said.

Comment on lines +2351 to +2355
df1.join(df2, how="cross")
df1.join(df2, how="inner")
df1.join(df2, how="outer")
df1.join(df2, how="left")
df1.join(df2, how="right")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you use the check(assert_type(... pattern here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mypy] Dataframe.Join with "cross" option for "how" argument throws error even though it's valid
2 participants