KEMBAR78
Fixes `bool` and `Literal[True, False]` subtyping, refs #11701 by sobolevn · Pull Request #11709 · python/mypy · GitHub
Skip to content

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