diff options
author | Guido van Rossum <guido@python.org> | 2016-04-18 14:37:41 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-04-18 14:37:41 (GMT) |
commit | 5abcbb3ee531ed7587b465d487ec9b4bab03a7ff (patch) | |
tree | 12042585038cfb6af374c346d1b49f8c6ef562d8 /Lib | |
parent | c1b578608ef397dcc7a64ff1228aa770e2b65cb2 (diff) | |
download | cpython-5abcbb3ee531ed7587b465d487ec9b4bab03a7ff.zip cpython-5abcbb3ee531ed7587b465d487ec9b4bab03a7ff.tar.gz cpython-5abcbb3ee531ed7587b465d487ec9b4bab03a7ff.tar.bz2 |
typing.py: Consider ellipsis in TupleMeta.__eq__. By Kalle Tuure. github.com/python/typing/pull/201.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_typing.py | 6 | ||||
-rw-r--r-- | Lib/typing.py | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index b39efcf..47118ed 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -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 diff --git a/Lib/typing.py b/Lib/typing.py index 42a9ea3..d275011 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -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__) |