Open
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