Skip to content

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

Merged
JukkaL merged 2 commits into
python:masterfrom
sobolevn:issue-11701
Dec 14, 2021
Merged

Fixes bool and Literal[True, False] subtyping, refs #11701#11709
JukkaL merged 2 commits into
python:masterfrom
sobolevn:issue-11701

Conversation

@sobolevn

@sobolevn sobolevn commented Dec 10, 2021

Copy link
Copy Markdown
Member

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

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor

thanks for fixing this!

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

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

4 participants