Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10731,6 +10731,9 @@ def test_eq(self):
with self.assertWarns(DeprecationWarning):
self.assertNotEqual(int, typing._UnionGenericAlias)

def test_hashable(self):
self.assertEqual(hash(typing._UnionGenericAlias), hash(Union))


def load_tests(loader, tests, pattern):
import doctest
Expand Down
3 changes: 3 additions & 0 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,9 @@ def __eq__(self, other):
return True
return NotImplemented

def __hash__(self):
return hash(Union)


class _UnionGenericAlias(metaclass=_UnionGenericAliasMeta):
"""Compatibility hack.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make the private class ``typing._UnionGenericAlias`` hashable.
Loading