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

Properly support union of TypedDicts as dict literal context #14505

Merged
merged 1 commit into from
Jan 23, 2023

Conversation

ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Jan 22, 2023

Fixes #14481 (regression)
Fixes #13274
Fixes #8533

Most notably, if literal matches multiple items in union, it is not an error, it is only an error if it matches none of them, so I adjust the error message accordingly.

An import caveat is that an unrelated error like {"key": 42 + "no"} can cause no item to match (an hence an extra error), but I think it is fine, since we still show the actual error, and avoiding this would require some dirty hacks.

Also note there was an (obvious) bug in one of the fixtures, that caused one of repros not repro in tests, fixing it required tweaking an unrelated test.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Looks good! Nice that this fixes an old type inference bug as well.

@JukkaL JukkaL merged commit d841859 into python:master Jan 23, 2023
@ilevkivskyi ilevkivskyi deleted the fix-td-union-context branch January 23, 2023 10:36
@jepperaskdk
Copy link

Awesome! What version will this be available in?

@ilevkivskyi
Copy link
Member Author

I guess it will be included in 1.0

@jepperaskdk
Copy link

@ilevkivskyi Cool, when is that set to launch?

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 26, 2023

1.0 should be out within the next week or two.

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