-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-reachabilityDetecting unreachable codeDetecting unreachable code
Description
Say I have function that maybe returns None
and I check the result:
def f() -> int | None: ...
if f() is None: ...
I rewrite the function so that it never returns None
:
def f() -> int: ...
if f() is None: ...
Now the is None
check makes no sense -- it will always fail. This is a mistake introduced in refactoring and it should be flagged. (And similar for is not None
checks)
In Rust I don't think this kind of error is possible:
fn f() -> Option<u8>;
if f().is_none() {} // okay
fn g() -> u8;
if g().is_none() {} // no good
risperss
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-reachabilityDetecting unreachable codeDetecting unreachable code