gh-132941: Soft deprecate various typing classes#154480
Conversation
Also use the newer type var syntax in a few places.
Documentation build overview
8 files changed ·
|
|
|
||
| .. deprecated:: 3.16 | ||
|
|
||
| Use :class:`typing.Union` instead. |
There was a problem hiding this comment.
Maybe we should suggest using |?
There was a problem hiding this comment.
The | syntax creates instances of typing.Union, which types.UnionType is now an alias for (as the line before indicates).
I think this is clear enough when combined with the previous line.
There was a problem hiding this comment.
I think both would be beneficial:
Use the ``X | Y`` syntax to create ``Union`` instances and :class:
typing.Unionfor all other purposes.
| See :pep:`585` and :ref:`types-genericalias`. | ||
|
|
||
| .. class:: Type(Generic[CT_co]) | ||
| .. class:: Type[CT_co] |
There was a problem hiding this comment.
I think when I tried to do this during the PEP 695 implementation it wasn't possible because Sphinx couldn't parse the syntax, definitely supportive of changing this.
There was a problem hiding this comment.
This seems fine now:
- https://cpython-previews--154480.org.readthedocs.build/en/154480/library/typing.html#typing.Type
- https://cpython-previews--154480.org.readthedocs.build/en/154480/library/typing.html#typing.MutableSequence
Although I missed a few instances, which I will add.
|
|
||
| This is now an alias for :class:`typing.Union`. | ||
|
|
||
| .. deprecated:: 3.16 |
There was a problem hiding this comment.
Is it soft-deprecated or deprecated?
| .. deprecated:: 3.16 | |
| .. soft-deprecated:: 3.16 |
If it's soft deprecated, also add them to the relevant file in the deprecations docs. If it's regular-deprecated, please schedule removal for a version.
Also use the newer type var syntax in a few places.
This PR does not deprecated
TypeVar,ParamSpec, andTypeVarTupleconstructors, as it is sometimes necessary to create type vars using the
explicit syntax. (For example to create a shared type var like
AnyStrorto use it as a type form.)
Cc @JelleZijlstra