bpo-28556: Don't simplify unions at runtime by ilevkivskyi · Pull Request #6841 · python/cpython (original) (raw)

this change breaks semantics of eq, now Union[Manager, Employee] != Employee. I can tweak eq, but the problem is that generics are cashed, so after once writing List[Employee], then writing List[Union[Manager, Employee]] will return List[Employee] thus again effectively simplifying a union.

Sorry, the tenses are confusing. Is the problem with List[Union[Manager, Employee]] returning List[Employee] happening with this version of the PR or would that happen if you "tweaked" __eq__?

Honestly given that we don't simplify unions I think it's right that Union[Manager, Employee] != Employee.