Commit 49ed08fd authored by Guido van Rossum's avatar Guido van Rossum

typing.py: merge 3.5->3.6 (Tuple/ellipsis/equality).

parents 27e1240a 5abcbb3e
...@@ -359,6 +359,12 @@ class TupleTests(TestCase): ...@@ -359,6 +359,12 @@ class TupleTests(TestCase):
self.assertTrue(issubclass(tuple, Tuple)) self.assertTrue(issubclass(tuple, Tuple))
self.assertFalse(issubclass(Tuple, tuple)) # Can't have it both ways. 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): def test_tuple_subclass(self):
class MyTuple(tuple): class MyTuple(tuple):
pass pass
......
...@@ -705,7 +705,8 @@ class TupleMeta(TypingMeta): ...@@ -705,7 +705,8 @@ class TupleMeta(TypingMeta):
def __eq__(self, other): def __eq__(self, other):
if not isinstance(other, TupleMeta): if not isinstance(other, TupleMeta):
return NotImplemented 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): def __hash__(self):
return hash(self.__tuple_params__) 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