-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
[0] + ["a"] is not allowed in any type checker (e.g. pyright, mypy) because the type annotation of list.__add__ is defined as follows:
class list(MutableSequence[_T], Generic[_T]):
...
def __add__(self, x: List[_T]) -> List[_T]: ...This annotation prohibits heterogeneous concatenation, although it is actually allowed in runtime.
I think the annotation should be as follows to solve this problem:
class list(MutableSequence[_T], Generic[_T]):
...
def __add__(self, x: List[_S]) -> List[Union[_T, _S]]: ...Metadata
Metadata
Assignees
Labels
No labels