Message403605
types.UnionType corresponds to typing._UnionGenericAlias, not typing.Union.
We can make (int | str | T)[dict] returning an instance of types.UnionType instead of an instance of typing._UnionGenericAlias. But it will be a breaking change, because typing._UnionGenericAlias and types.UnionType are different and not completely compatible types. We should wait some time before making such changes, so all user code will be made supporting both typing._UnionGenericAlias and types.UnionType.
If the user code does something special like substituting `int | Collection[int]` to `int | list[int]`, it should have some additional ifs in any case, otherwise it will not recognize new typing types including types.UnionTypes. And subscription does not work in all typing types, we have copy_with() for some types and special cases for others in the code of the typing module. I am going to unify it finally, but it takes time, my time and user's time to migrate to new idioms. |
|
Date |
User |
Action |
Args |
2021-10-10 18:36:04 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, joperez, kj |
2021-10-10 18:36:04 | serhiy.storchaka | set | messageid: <1633890964.25.0.252682399558.issue45418@roundup.psfhosted.org> |
2021-10-10 18:36:04 | serhiy.storchaka | link | issue45418 messages |
2021-10-10 18:36:04 | serhiy.storchaka | create | |
|