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

Fixes bool and Literal[True, False] subtyping, refs #11701 #11709

Merged
merged 2 commits into from
Dec 14, 2021
Merged

Fixes bool and Literal[True, False] subtyping, refs #11701 #11709

merged 2 commits into from
Dec 14, 2021

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Dec 10, 2021

In some places in our code bool was compared with Union[Literal[True], Literal[False]].
It was later compared with each union item. And bool is not subtype of Literal[True] and Literal[False]

Closes #11701
Refs #11705

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for this. #10389 was super useful, so glad we're fixing regressions.

Seems like this logic is coupled to try_expanding_sum_type_to_union, we should probably put a comment in both places

@ethan-leba
Copy link
Contributor

thanks for fixing this!

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.

Thanks!

@JukkaL JukkaL merged commit ef43416 into python:master Dec 14, 2021
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
…ython#11709)

In some places in our code bool was compared with `Union[Literal[True], Literal[False]]`.
It was later compared with each union item. And bool is not subtype of 
`Literal[True]` and `Literal[False]`.

Closes python#11701
Refs python#11705
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.

Literal[True, False] false positives within tuples
4 participants