Kaydet (Commit) 5abcbb3e authored tarafından Guido van Rossum's avatar Guido van Rossum

typing.py: Consider ellipsis in TupleMeta.__eq__. By Kalle Tuure.…

typing.py: Consider ellipsis in TupleMeta.__eq__. By Kalle Tuure. github.com/python/typing/pull/201.
üst c1b57860
......@@ -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
......
......@@ -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__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment