Open
Description
Consider the following code:
from dataclasses import dataclass
@dataclass
class Foo:
value: int
modified: bool = False
def update(self) -> None:
self.value += 1
self.modified = True
foo = Foo(42)
assert not foo.modified
foo.update()
assert foo.modified
print("Reached")
When this is run, the print("Reached")
line is reached, but mypy doesn't seem to realize that. Running mypy --warn-unreachable --pretty
on the above code gives:
unreachable03.py:18: error: Statement is unreachable
print("Reached")
^
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: both v0.931 and the GitHub version as of commit 48d810d
- Mypy command-line flags:
--warn-unreachable --pretty
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.9.9
- Operating system and version: macOS 11.6