From 22cb7d1441af2d8f0fda8a99dc3226688e87f722 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 22 Sep 2019 17:28:16 -0700 Subject: [PATCH 1/3] Modified __add__ method in tuple class to allow it to accept tuples with different generic parameter types. This allows, for example: a = (1, ) b = a + (2.4, ) --- stdlib/2and3/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 680f1fd7b06a..2d0fd6515fa8 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -867,7 +867,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[...]) -> Tuple[_T_co, ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ... From 3946c184f28e94298a1337306b2a37f15d4da90a Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 24 Sep 2019 09:23:36 -0700 Subject: [PATCH 2/3] Based on PR discussion, added overload for tuple `__add__` method. --- stdlib/2and3/builtins.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 2d0fd6515fa8..e85009af027d 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -867,7 +867,10 @@ 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[...]) -> Tuple[_T_co, ...]: ... + @overload + def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... + @overload + def __add__(self, x: tuple) -> tuple: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ... From c14076ee382ce8f0a3ef983584ff072cbbd057f1 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 28 Sep 2019 23:27:13 -0700 Subject: [PATCH 3/3] Sync'ed changes from builtins.pyi into __builtin__.pyi. --- stdlib/2/__builtin__.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 680f1fd7b06a..e85009af027d 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -867,7 +867,10 @@ 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: ... + @overload def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... + @overload + def __add__(self, x: tuple) -> tuple: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ...