-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Unioned types should be hashable: not documented? #112281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
PEPs https://peps.python.org/pep-0593/#specification and https://peps.python.org/pep-0604/ do not say anything about requirement of items to be hashable. I think that this is a bug: unhashable items must be allowed. I think that we need to rework our Thanks for the report! 👍 |
This is more complex than I initially thought, because Line 1536 in ce1096f
|
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…ythonGH-112283) (cherry picked from commit a7549b0) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…adata (pythonGH-112283) (cherry picked from commit a7549b0) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…ython#112283) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…ython#112283) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…ython#112283) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Documentation
It seems that
typing.Union[X, Y]
as well asX | Y
type hints requireX
andY
to be hashable.This is not documented as far as I can see.
Considering this example:
This fails when unioned:
Should this be documented say here: https://docs.python.org/3/library/typing.html?highlight=typing#typing.Annotated ?
And examples here should use frozen dataclasses: https://docs.python.org/3/library/typing.html?highlight=typing#typing.Annotated ?
Linked PRs
Union
with unhashableAnnotated
metadata #112283Union
with unhashableAnnotated
metadata (GH-112283) #116213Union
with unhashableAnnotated
metadata (GH-112283) #116288The text was updated successfully, but these errors were encountered: