]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
typing.py: Consider ellipsis in TupleMeta.__eq__. By Kalle Tuure. github.com/python...
authorGuido van Rossum <guido@python.org>
Mon, 18 Apr 2016 14:37:41 +0000 (07:37 -0700)
committerGuido van Rossum <guido@python.org>
Mon, 18 Apr 2016 14:37:41 +0000 (07:37 -0700)
Lib/test/test_typing.py
Lib/typing.py

index b39efcf01913d81ef3c41b3b2eabd1ed8bd646f4..47118edc691984c28c2d7926405e46b0978dcba5 100644 (file)
@@ -359,6 +359,12 @@ class TupleTests(TestCase):
         self.assertTrue(issubclass(tuple, Tuple))
         self.assertFalse(issubclass(Tuple, tuple))  # Can't have it both ways.
 
+    def test_equality(self):
+        assert Tuple[int] == Tuple[int]
+        assert Tuple[int, ...] == Tuple[int, ...]
+        assert Tuple[int] != Tuple[int, int]
+        assert Tuple[int] != Tuple[int, ...]
+
     def test_tuple_subclass(self):
         class MyTuple(tuple):
             pass
index 42a9ea3d660c82bc7a4e338b2cf9bb3234fd3572..d2750111d4502e159108767206e1796675033392 100644 (file)
@@ -705,7 +705,8 @@ class TupleMeta(TypingMeta):
     def __eq__(self, other):
         if not isinstance(other, TupleMeta):
             return NotImplemented
-        return self.__tuple_params__ == other.__tuple_params__
+        return (self.__tuple_params__ == other.__tuple_params__ and
+                self.__tuple_use_ellipsis__ == other.__tuple_use_ellipsis__)
 
     def __hash__(self):
         return hash(self.__tuple_params__)