Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created October 31, 2022 12:40
Show Gist options
  • Save mypy-play/c4a0b051484c30474289868dd9ceb8e5 to your computer and use it in GitHub Desktop.
Save mypy-play/c4a0b051484c30474289868dd9ceb8e5 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Optional
# executed with --warn-unreachable
class A:
x: Optional[int]
def execute(self) -> None:
self.x = None
for i in range(3):
if self.x is None:
self.x = 10
else:
self.x = 20 # error: Statement is unreachable [unreachable]
print(self.x)
a = A()
a.execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment