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

(🐞) isinstance doesn't work with unions containing None #17413

Closed
KotlinIsland opened this issue Jun 21, 2024 · 1 comment · Fixed by #17415
Closed

(🐞) isinstance doesn't work with unions containing None #17413

KotlinIsland opened this issue Jun 21, 2024 · 1 comment · Fixed by #17415
Labels
bug mypy got something wrong topic-pep-604 PEP 604 (union | operator)

Comments

@KotlinIsland
Copy link
Contributor

value: str | bool | None
assert not isinstance(value, str | None)
reveal_type(value)  # str | bool | None
value: object
assert isinstance(value, str | None)
reveal_type(value)  # object
@KotlinIsland KotlinIsland added the bug mypy got something wrong label Jun 21, 2024
@hauntsaninja hauntsaninja added the topic-pep-604 PEP 604 (union | operator) label Jun 21, 2024
hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Jun 21, 2024
@hauntsaninja
Copy link
Collaborator

Thanks for the issue, looks pretty easy to fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-pep-604 PEP 604 (union | operator)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants