bpo-42345: Fix hash implementation of typing.Literal (GH-23383)

Fix hash implementation of `typing.Literal`.

Update docs regarding `typing.Litaral` caching.

Base implementation was done in PR #23294.
This commit is contained in:
Yurii Karabas 2020-11-19 18:17:38 +02:00 committed by GitHub
parent b437aa83f9
commit 1b54077ff6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View file

@ -981,7 +981,7 @@ class _LiteralGenericAlias(_GenericAlias, _root=True):
return set(_value_and_type_iter(self.__args__)) == set(_value_and_type_iter(other.__args__))
def __hash__(self):
return hash(tuple(_value_and_type_iter(self.__args__)))
return hash(frozenset(_value_and_type_iter(self.__args__)))
class Generic: