From 1a42a2c3eafbd582462962c664bf09b2fea7f10a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 8 Nov 2018 06:42:57 -0800 Subject: [PATCH] fix list concatenation (#2404) Fixes #2383, python/mypy#5492. --- stdlib/2/__builtin__.pyi | 6 +++--- stdlib/2/builtins.pyi | 6 +++--- stdlib/3/builtins.pyi | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index a29829838..9a5350ee2 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -547,7 +547,7 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __le__(self, x: Tuple[_T_co, ...]) -> bool: ... def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ... def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... + def __add__(self, x: Tuple[_S, ...]) -> Tuple[Union[_T_co, _S], ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ... @@ -589,8 +589,8 @@ class list(MutableSequence[_T], Generic[_T]): def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... def __delitem__(self, i: Union[int, slice]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, x: List[_T]) -> List[_T]: ... - def __iadd__(self, x: Iterable[_T]) -> List[_T]: ... + def __add__(self, x: List[_S]) -> List[Union[_T, _S]]: ... + def __iadd__(self, x: Iterable[_T]) -> List[_T]: ... # type: ignore def __mul__(self, n: int) -> List[_T]: ... def __rmul__(self, n: int) -> List[_T]: ... def __contains__(self, o: object) -> bool: ... diff --git a/stdlib/2/builtins.pyi b/stdlib/2/builtins.pyi index a29829838..9a5350ee2 100644 --- a/stdlib/2/builtins.pyi +++ b/stdlib/2/builtins.pyi @@ -547,7 +547,7 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __le__(self, x: Tuple[_T_co, ...]) -> bool: ... def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ... def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... + def __add__(self, x: Tuple[_S, ...]) -> Tuple[Union[_T_co, _S], ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ... @@ -589,8 +589,8 @@ class list(MutableSequence[_T], Generic[_T]): def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... def __delitem__(self, i: Union[int, slice]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, x: List[_T]) -> List[_T]: ... - def __iadd__(self, x: Iterable[_T]) -> List[_T]: ... + def __add__(self, x: List[_S]) -> List[Union[_T, _S]]: ... + def __iadd__(self, x: Iterable[_T]) -> List[_T]: ... # type: ignore def __mul__(self, n: int) -> List[_T]: ... def __rmul__(self, n: int) -> List[_T]: ... def __contains__(self, o: object) -> bool: ... diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index d3f56b4db..f30ee9d48 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -589,7 +589,7 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __le__(self, x: Tuple[_T_co, ...]) -> bool: ... def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ... def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... + def __add__(self, x: Tuple[_S, ...]) -> Tuple[Union[_T_co, _S], ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ... @@ -636,8 +636,8 @@ 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, x: Iterable[_T]) -> List[_T]: ... + def __add__(self, x: List[_S]) -> List[Union[_T, _S]]: ... + def __iadd__(self, x: Iterable[_T]) -> List[_T]: ... # type: ignore def __mul__(self, n: int) -> List[_T]: ... def __rmul__(self, n: int) -> List[_T]: ... def __imul__(self, n: int) -> List[_T]: ...