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

Fix join of Any against a union type #12068

Merged
merged 2 commits into from
Jan 25, 2022
Merged

Fix join of Any against a union type #12068

merged 2 commits into from
Jan 25, 2022

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jan 25, 2022

Make the join of a union type and Any commutative.
Previously the result dependend on the order of the operands,
which was clearly incorrect.

Fix #12051, but other use cases are affected as well.

This change was split off from #12054.

Make the join of a union type and Any commutative.
Previously the result dependend on the order of the operands,
which was clearly incorrect.

Fix #12051, but other use cases are affected as well.
@@ -1881,4 +1881,8 @@ class C(IntEnum):
def f1(c: C) -> None:
x = {'x': c.value}
reveal_type(x) # N: Revealed type is "builtins.dict[builtins.str*, builtins.int]"

def f2(c: C, a: Any) -> None:
x = {'x': c.value, 'y': a}
Copy link
Member

Choose a reason for hiding this comment

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

Will y = {'y': a, 'x': c.value} be helpful here as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good idea, I'll add it here.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Jan 25, 2022

I'm going to merge this without waiting for code review, since the changes was approved in #12054.

@JukkaL JukkaL merged commit fb94f80 into master Jan 25, 2022
@JukkaL JukkaL deleted the fix-union-join branch January 25, 2022 16:44
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.

Unexpected type inference changes related to enum value attributes
2 participants