Thank you for the detailed explanation of the Steering Council’s thinking. I think that reversion of this change so late in the release candidate phase or even in the post-release bugfix phase would bring less harm than keeping it for the period necessary for deprecation, but I accept your decision. Any chance to start deprecation in 3.14.1 instead of 3.15, considering it a bug fix?
The following operations should be deprecated:
-
types.UnionType[...]. Becausetypes.UnionTypeis a class, but not a generic class.But
typing.Union[...]should be kept – this is the purpose oftyping.Union. -
isinstance(..., typing.Union)andissubclass(..., typing.Union). Becausetyping.Unionis not a type, it is a special form used to create type unions. Using it in the type checks is the same as usingtyping.Literalortyping.Finalin the type checks.But
isinstance(..., types.UnionType)andissubclass(..., types.UnionType)should be kept – I suppose this was the primary reason of exposingtypes.UnionTypeto public. -
Some dunder attributes and methods like
__origin__,__args__,__qualname__or__mro_entries__()– but I cannot say right now which of them are harmless and are useless. We can leave this for later.
To do this, we need to separate types.UnionType and typing.Union and make the latter imitating the former. This itself is a breaking change.