-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-reachabilityDetecting unreachable codeDetecting unreachable code
Description
Here is a full example:
from random import randrange def f(x: int) -> int | None: return None if x == 0 else 2 * x def g(x: int) -> int: return 2 * x if __name__ == '__main__': if f(randrange(10)) is None: print('f: got 0') if g(randrange(10)) is None: # <-- unreachable but not flagged print('g: got 0')
mypy --strict --warn-unreachabledoes not raise any warnings, but it should. So this is a FALSE NEGATIVE bug. Or a new feature, whatever, but in any case this situation should be flagged.
Originally posted by @nickdrozd in #18386
This might be intentional, but I think it's counterintuitive and I can't really see a benefit. Making an issue to make sure I get around to investigating this.
wyattscarpenter
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-reachabilityDetecting unreachable codeDetecting unreachable code