Closed as not planned
Description
Bug Report
Consider the following code:
def f(a: bool, x: int | None) -> None:
if a:
if x is None:
raise ValueError
if a:
g(x)
h()
def g(x: int) -> None:
pass
def h() -> None:
pass
It is clear that, when g(x)
is called, x
is an int
, because None is already excluded.
Unfortunately, we have the following error:
demo.py: note: In function "f":
demo.py:7:11:7:11: error: Argument 1 to "g" has incompatible type "int | None"; expected "int" [arg-type]
g(x)
^
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.15.0
- Mypy command-line : None (execution via uv run)
- Mypy configuration options from
pyproject.toml
:
[tool.mypy]
strict = true
show_error_context = true
show_column_numbers = true
show_error_end = true
show_error_code_links = true
pretty = true
mypy_path = "$MYPY_CONFIG_FILE_DIR/src"
packages = ['qbdseroconv', ]
- Python version used: 3.12.3