Skip to content

Commit

Permalink
Make union support unhashable objects
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Sep 28, 2024
1 parent 65da3f1 commit f500f5f
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 250 deletions.
10 changes: 2 additions & 8 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,16 +2062,10 @@ class B(metaclass=UnhashableMeta): ...

self.assertEqual(Union[A, B].__args__, (A, B))
union1 = Union[A, B]
with self.assertRaises(TypeError):
hash(union1)

union2 = Union[int, B]
with self.assertRaises(TypeError):
hash(union2)

union3 = Union[A, int]
with self.assertRaises(TypeError):
hash(union3)

self.assertEqual(len({union1, union2, union3}), 3)

def test_repr(self):
u = Union[Employee, int]
Expand Down
Loading

0 comments on commit f500f5f

Please sign in to comment.