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
disambiguators.create_uniq_field_dis_func fails to disambiguate ambiguous unions depending on parameter order #230
In some cases, create_uniq_field_dis_func fails to disambiguate certain unions. The order of arguments matter, which can cause some confusion if eg. the arguments are taken from a set with no strict ordering, because it sometimes works, and sometimes fails.
Consider the following program:
importattrs, cattrs# the fields are named after the classes they share@attrs.defineclassA:
ab: inta: str@attrs.defineclassB:
ab: intbc: int@attrs.defineclassC:
bc: intcattrs.disambiguators.create_uniq_field_dis_func(A, B, C) # no errorcattrs.disambiguators.create_uniq_field_dis_func(B, A, C) # ValueError: <class '__main__.B'> has no usable unique attributes.
Another case where this can bite people is if Union[A, B, C] was defined, and the code works, then later on, somebody defines Union[B, A, C] in a module that is executed earlier. Python will convert the types into whatever was defined first, so suddenly, Union[A, B, C] is treated like Union[B, A, C]
changed the title [-]disambiguators.create_uniq_field_dis_func fails to disambiguate unions depending on parameter order[/-][+]disambiguators.create_uniq_field_dis_func fails to disambiguate ambiguous unions depending on parameter order[/+]on Feb 16, 2022
Activity
[-]disambiguators.create_uniq_field_dis_func fails to disambiguate unions depending on parameter order[/-][+]disambiguators.create_uniq_field_dis_func fails to disambiguate ambiguous unions depending on parameter order[/+]Disambiguate unions independent of member class order
Disambiguate unions independent of member class order