Bug Report
Mypy reports Unsupported operand types for + when concatenating two lists, when the second operand is a subtype of the first.
This was previously mentioned in this comment in #5492
Below is a simple concise example
To Reproduce
classA:
passclassB(A):
passdeffoo(a: list[A]) ->None:
passl1: list[A] = [A(), B()]
l2: list[B] = [B()]
l3=l1+l2foo(l2+l1) # OK, no errorfoo(l3) # also OKfoo(
l1+l2
) # ERROR: Unsupported operand types for + ("List[A]" and "List[B]") [operator]mypy(error)gist link
Expected Behavior
No error on the last line
Actual Behavior
Reports spurious error
Your Environment
- Mypy version used: mypy 1.2.0
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini (and other config files): from pyproject.toml
ignore_missing_imports = true
show_column_numbers = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_unused_configs = true
follow_imports = "normal"
plugins = ["pydantic.mypy"]
- Python version used: 3.10
Bug Report
Mypy reports
Unsupported operand types for +when concatenating two lists, when the second operand is a subtype of the first.This was previously mentioned in this comment in #5492
Below is a simple concise example
To Reproduce
gist link
Expected Behavior
No error on the last line
Actual Behavior
Reports spurious error
Your Environment
mypy.ini(and other config files): from pyproject.toml