Closed as not planned
Description
Bug Report
I would expect a variable that gets imported narrow the type.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=11a4883cf29edd47fd1aff15302ead30
x: str | None = None
if x is None:
from os import sep as x
# revealed type is Optional[str]
print(x + "a") # mypy false positive
Expected Behavior
No error.
Actual Behavior
% mypy test.py
main.py:5: error: Unsupported left operand type for + ("None") [operator]
main.py:5: note: Left operand is of type "Optional[str]"
Found 1 error in 1 file (checked 1 source file)
% python test.py
/a
Your Environment
- Mypy version used: 1.1.1
- Mypy command-line flags: none
- Python version used: 3.11