Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3k
Open
Description
Bug Report
Mypy reportsUnsupported operand types for +
when concatenating two lists, when the second operand is a subtype of the first.
This was previously mentioned inthis 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)
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 = trueshow_column_numbers = truewarn_redundant_casts = truewarn_unused_ignores = truewarn_unused_configs = truefollow_imports = "normal"plugins = ["pydantic.mypy"]
- Python version used: 3.10