python / python/cpython

typing docs: Use soft deprecation

Open
#132,941 8 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs topic-typing
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

A while ago we introduced the concept of "soft deprecation" in PEP 387 (https://peps.python.org/pep-0387/#soft-deprecation): for things that we no longer recommend using, but which we aren't planning to remove in the near future.

The typing docs already list four classes of objects that are deprecated without a scheduled removal (https://docs.python.org/3.14/library/typing.html#deprecation-timeline-of-major-features):

  • Pre-PEP-585 generic aliases (e.g. List)
  • Text
  • Hashable and Sized
  • TypeAlias

I'd like to also soft-deprecate the following:

  • Optional (obviated by PEP-604)
  • NoReturn (prefer Never)
  • typing.ForwardRef (deprecated alias for annotationlib.ForwardRef)
  • types.UnionType (deprecated alias for typing.Union)
  • Creating a Union using subscripting (Union[A, B] instead of A | B) (PEP-604)
  • Creating a TypeVar, ParamSpec, or TypeVarTuple using the constructor directly (PEP-695)
  • Directly inheriting from Generic (PEP-695)

None of those will be removable for many years if ever, but I think it's useful to have a clear statement in the docs that the newer syntax is preferred.

Linked PRs
  • gh-154480

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typing documentation section titled “Deprecation timeline of major features” at the linked Python documentation page, and compare its existing entries with the requested soft deprecations. Done means the documentation clearly identifies the listed older forms and recommends their newer alternatives; review linked PR gh-154480 first because work is already associated with it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.