You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
typing._UnionGenericAlias is unhashable in 3.14 #133925
typing._UnionGenericAlias) became unshable somewhere between 3.13 and 3.14.0b1 (most likely in gh-105511)
importtypinghash(typing._UnionGenericAlias)
Traceback (most recent call last):
File "<python-input-0>", line 2, in <module>hash(typing._UnionGenericAlias)
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^TypeError: unhashable type: '_UnionGenericAliasMeta'
This was hit in a doctest from astropy: xref astropy/astropy#18126
To be clear, the test in question doesn't necessarily correspond to a real-life application; we're testing that our itersubclasses utility function works in a very broad case where we try to retrieve all defined subclasses of object, and do a bit of internal book-keeping using a set of already-visited classes. This used to work in Python 3.13 (and seems to have worked with no interruption for 10+ years), so it still seemed worth a shot to see if that would be considered a bug here. Otherwise, it should be possible to fix the function on our side to either special case this exact class, ignore any unhashable class, or avoid reequiring hashability altogether.
Activity
hugovk commentedon May 12, 2025
Git bisect agrees, cc @JelleZijlstra.
pythongh-133925: Make typing._UnionGenericAlias hashable
JelleZijlstra commentedon May 12, 2025
It's because I added
__eq__but not__hash__to the metaclass. Fix in #133929.gh-133925: Make typing._UnionGenericAlias hashable (#133929)
pythongh-133925: Make typing._UnionGenericAlias hashable (pythonGH-13…
[3.14] gh-133925: Make typing._UnionGenericAlias hashable (GH-133929) (…
neutrinoceros commentedon May 12, 2025
Is there a reason to keep this open after the fox was merged ?
AlexWaygood commentedon May 12, 2025
no, this is done now that the 🦊 is merged
neutrinoceros commentedon May 12, 2025
Thanks, all !
Allow coverage issues
pythongh-133925: Make typing._UnionGenericAlias hashable (python#133929)
pythongh-133925: Make typing._UnionGenericAlias hashable (python#133929)