Closed Zereges closed 6 months ago
Hm, this is a though one. The TaggedValue
needs to hash to the same hash-value as the tuple it represents, so that they can be used interchangeably as dict-keys. This is need by the feature introduced in #433 to make tuple-pair and hint compatible.
I agree that it technically shouldn'd need to be hashed if no hints are provided, so I will check that if I find some time.
But as tuples in general repersend immutable data it can usually be assumed that they are hashable and this is not really a regression, instead your usecase only happend to work before due to pythons loose enforcment of such things
as you suggested, it is easy enough to just skip the whole hints part if its not needed, avoiding the issue.
In 3.2.1, the following worked:
Whereas in 3.2.2 (and 3.2.3) this doesn't:
The reason is that
TaggedValue
'shash
function tries to hash whole tuple passed. Would it be enough to hash just the string representation (i.e.hash(self.tag)
), instead of the whole tuple? I'd say the list of choices should provide unique string descriptions for every item (although it might technically not be necessary when passinghints=
as well?)