Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Union type for List.__add__ #3183

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions stdlib/2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,10 @@ class list(MutableSequence[_T], Generic[_T]):
def __getslice__(self, start: int, stop: int) -> List[_T]: ...
def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ...
def __delslice__(self, start: int, stop: int) -> None: ...
def __add__(self, x: List[_T]) -> List[_T]: ...
def __iadd__(self: _S, x: Iterable[_T]) -> _S: ...
def __add__(self, x: List[_S]) -> List[Union[_T, _S]]: ...
def __iadd__(self, x: Iterable[_S]) -> List[Union[_T, _S]]: ...
# Workaround https://github.com/python/mypy/issues/5971
def __radd__(self, x: List[_S]) -> List[Union[_T, _S]]: ...
def __mul__(self, n: int) -> List[_T]: ...
def __rmul__(self, n: int) -> List[_T]: ...
def __contains__(self, o: object) -> bool: ...
Expand Down
6 changes: 4 additions & 2 deletions stdlib/2/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,10 @@ class list(MutableSequence[_T], Generic[_T]):
def __getslice__(self, start: int, stop: int) -> List[_T]: ...
def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ...
def __delslice__(self, start: int, stop: int) -> None: ...
def __add__(self, x: List[_T]) -> List[_T]: ...
def __iadd__(self: _S, x: Iterable[_T]) -> _S: ...
def __add__(self, x: List[_S]) -> List[Union[_T, _S]]: ...
def __iadd__(self, x: Iterable[_S]) -> List[Union[_T, _S]]: ...
# Workaround https://github.com/python/mypy/issues/5971
def __radd__(self, x: List[_S]) -> List[Union[_T, _S]]: ...
def __mul__(self, n: int) -> List[_T]: ...
def __rmul__(self, n: int) -> List[_T]: ...
def __contains__(self, o: object) -> bool: ...
Expand Down
6 changes: 4 additions & 2 deletions stdlib/3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,10 @@ class list(MutableSequence[_T], Generic[_T]):
@overload
def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...
def __add__(self, x: List[_T]) -> List[_T]: ...
def __iadd__(self: _S, x: Iterable[_T]) -> _S: ...
def __add__(self, x: List[_S]) -> List[Union[_T, _S]]: ...
def __iadd__(self, x: Iterable[_S]) -> List[Union[_T, _S]]: ...
# Workaround https://github.com/python/mypy/issues/5971
def __radd__(self, x: List[_S]) -> List[Union[_T, _S]]: ...
def __mul__(self, n: int) -> List[_T]: ...
def __rmul__(self, n: int) -> List[_T]: ...
def __imul__(self: _S, n: int) -> _S: ...
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_whitelists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ builtins.classmethod.__get__
builtins.complex.__complex__
builtins.ellipsis
builtins.function
builtins.list.__radd__
builtins.memoryview.__contains__
builtins.memoryview.__iter__
builtins.memoryview.cast
Expand Down