This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients gvanrossum, joperez, kj, serhiy.storchaka
Date 2021-10-10.18:36:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633890964.25.0.252682399558.issue45418@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-10-10 18:36:04serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, joperez, kj
2021-10-10 18:36:04serhiy.storchakasetmessageid: <1633890964.25.0.252682399558.issue45418@roundup.psfhosted.org>
2021-10-10 18:36:04serhiy.storchakalinkissue45418 messages
2021-10-10 18:36:04serhiy.storchakacreate