From 468d13a2059fa1c74cbc9fc467472da5f0f6391b Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 30 Sep 2019 03:42:40 -0700 Subject: [PATCH] Modified __add__ method in tuple class (#3252) 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/2/__builtin__.pyi | 3 +++ stdlib/2and3/builtins.pyi | 3 +++ 2 files changed, 6 insertions(+) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 433bfdfa0..9b4c83dc8 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: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 433bfdfa0..9b4c83dc8 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: ... + @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: ...