]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-149995: Update typing.py docstrings and documentation (#149996)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Fri, 22 May 2026 04:06:42 +0000 (21:06 -0700)
committerGitHub <noreply@github.com>
Fri, 22 May 2026 04:06:42 +0000 (21:06 -0700)
commitf159419ae2ef1aebbd90ce9427b55e27738c960c
tree4dfc4ea7bfddb0d49c0daef3fda5206edf6d7239
parentc613f72eeef83340cb369287f7c1a195e086d1d5
gh-149995: Update typing.py docstrings and documentation (#149996)

Some of these docstrings read as if they were written when typing.py was
first written, and things have evolved since then.

A few motivations:
- Call protocols protocols instead of ABCs. They are also ABCs, but the fact
  they are protocols is more relevant to typing.
- Avoid recommending direct use of .__annotations__ and steer users to
  annotationlib instead.
- For TypedDict, mention NotRequired before total=False since it is more
  general and probably more frequently useful.
- For overloads, mention runtime use first instead of stub use. I think early on
  there was talk of allowing overload only in stubs, but it is now heavily used at
  runtime too and that's more likely to be relevant to users.
Doc/library/typing.rst
Lib/typing.py
Misc/NEWS.d/next/Library/2026-05-18-07-44-46.gh-issue-149995.vvtFHn.rst [new file with mode: 0644]