This happens because mypy does not execute code for Literal[False] branches in if.
Check this:
"""All three of these assert_type should fail, but only one does, currently."""importtyping_extensionsastdeff(x: int|bool):
ifisinstance(x, str):
reveal_type(x) # not executed
Activity
sobolevn commented on Oct 24, 2023
This happens because mypy does not execute code for Literal[False] branches in if.
Check this:
sobolevn commented on Oct 24, 2023
This does not look like a bug to me.