Closed as duplicate of#11969
Closed as duplicate of#11969
Description
Bug Report
See code.
To Reproduce
from typing import Optional
class Global:
attr: Optional[int] = None
G = Global()
def f() -> None:
G.attr = 1
def t() -> None:
G.attr = None
f()
assert G.attr is not None
reveal_type(G)
- Write the above code
- Run mypy on it
Expected Behavior
Mypy shows the type of G
at the last line (and G.attr
is of type int
).
Actual Behavior
Mypy completely skips the lines below assert
.
Success: no issues found in 1 source file
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: no other args than the file
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.9.6
- Operating system and version: Arch Linux current