GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing github.com — Unioned types should be hashable: not documented? · Issue #112281 · python/cpython Closed Labels DescriptionDocumentationIt seems that This is not documented as far as I can see. Considering this example: @dataclass class ValueRange: lo: int hi: int T1 = Annotated[int, ValueRange(-10, 5)] This fails when unioned: >>> Annotated[int, ValueRange(-10, 5)] | None (...) File "/usr/lib64/python3.11/typing.py", line 1375, in __or__ return Union[self, right] ~~~~~^^^^^^^^^^^^^ File "/usr/lib64/python3.11/typing.py", line 358, in inner return func(*args, **kwds) ^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/typing.py", line 481, in __getitem__ return self._getitem(self, parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/typing.py", line 695, in Union parameters = _remove_dups_flatten(parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/typing.py", line 326, in _remove_dups_flatten return tuple(_deduplicate(params)) ^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/typing.py", line 301, in _deduplicate all_params = set(params) ^^^^^^^^^^^ File "/usr/lib64/python3.11/typing.py", line 2151, in __hash__ return hash((self.__origin__, self.__metadata__)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unhashable type: 'ValueRange' 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 PRsReacted by Daniel Gellert Activity
MetadataMetadataAssigneesLabelsProjectsMilestoneRelationshipsDevelopmentIssue actions | ||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |