Description
Bug Report
Error [list-item] is incorrectly raised. I tried various ways but none of them succeeded to convince mype
To Reproduce
from collections import deque
_table: str = "smth"
_columns: list[str] | None = None
queue: deque[tuple[str, str | None]] = deque(
(_table, c) for c in _columns or [None]
)
Expected Behavior
No error
Actual Behavior
mypy.py:7: error: List item 0 has incompatible type
"None"; expected "str" [list-item]
(_table, c) for c in (_columns or [None])
Your Environment
-
linux ubuntu
-
Mypy version used: 1.15
-
Mypy command-line flags: None
-
Mypy configuration options from
mypy.ini
(and other config files):
# mypy
[tool.mypy]
python_version = 3.12
pretty = true
strict = true
ignore_missing_imports = true
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true # Type-checks the interior of functions without type annotations.
disable_error_code = ["no-untyped-call", "type-arg", "no-untyped-def", "union-attr"][[tool.mypy.overrides]] module = "tests.*" ignore_errors = true
-
Python version used: 3.12
Activity
sterliakov commentedon May 28, 2025
Deque is a red herring here, the following reproduces the same issue: