mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +00:00
typing.py: Consider ellipsis in TupleMeta.__eq__. By Kalle Tuure. github.com/python/typing/pull/201.
This commit is contained in:
parent
c1b578608e
commit
5abcbb3ee5
2 changed files with 8 additions and 1 deletions
|
|
@ -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):
|
||||||
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__)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue