Open
Description
Bug Report
mypy can recognize sys.platform
in if cond: ... / else: ...
conditions but fails to do it if ternary operator (a if cond else b
) is used.
To Reproduce
Consider this piece of code, assuming we are on Linux:
import signal
import sys
signal_type = signal.SIGBREAK if sys.platform == 'win32' else signal.SIGTERM
Expected Behavior
mypy should not raise any error.
Actual Behavior
mypy fails with:
main.py:4: error: Module has no attribute "SIGBREAK"
Found 1 error in 1 file (checked 1 source file)
Environment
- Mypy version used: 0.961
- Python version used: 3.10
- Operating system: Linux