Closed as duplicate of#10773
Description
import sys
def foo() -> None:
if sys.platform != "darwin":
print("not darwin")
return
print("darwin")
$ mypy --platform linux plat.py
plat.py: note: In function "foo":
plat.py:9:5: error: Statement is unreachable [unreachable]
print("darwin")
^~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)
mypy
claims to understand sys.platform
checks, yet is defeated by !=
.
I would expect mypy
not to warn about unreachable code here:
- I am not assigning
sys.platform
to an intermediate - I am checking against a literal value (which in the documentation mypy also claims to understand).