Skip to content

Fix 0.750 regression: union (non-)simplification should not affect inference #8077

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 3 commits into from
Dec 4, 2019

Conversation

ilevkivskyi
Copy link
Member

Fixes #8051

The fix is as discussed in the issue. I didn't find a test case for the union actual, but I think it makes sense to simplify it as well. Note: I add the pythoneval test just as a regression test, if you think it is not worth it, I can remove it.

Unverified

The key that signed this is expired.
…ference
@ilevkivskyi ilevkivskyi requested a review from JukkaL December 4, 2019 16:54
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.

LGTM

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@@ -108,6 +108,12 @@ def _infer_constraints(template: Type, actual: Type,
template = get_proper_type(template)
actual = get_proper_type(actual)

# Type inference shouldn't be affected by whether union types have bee simplified.
Copy link
Member

Choose a reason for hiding this comment

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

typo: been

@@ -3646,7 +3646,7 @@ def test_narrow_none() -> None:
a: Optional[int]
if int():
a = narrow_none(a)
reveal_type(a) # N: Revealed type is 'Union[builtins.int, None]'
reveal_type(a) # N: Revealed type is 'builtins.int'
Copy link
Member

Choose a reason for hiding this comment

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

This is a nice improvement too.

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 0.750 regression with asyncio.wait
3 participants