Skip to content

gh-149995: Update typing.py docstrings and documentation#149996

Open
JelleZijlstra wants to merge 7 commits into
python:mainfrom
JelleZijlstra:typingdocstrings
Open

gh-149995: Update typing.py docstrings and documentation#149996
JelleZijlstra wants to merge 7 commits into
python:mainfrom
JelleZijlstra:typingdocstrings

Conversation

@JelleZijlstra
Copy link
Copy Markdown
Member

@JelleZijlstra JelleZijlstra commented May 18, 2026

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.

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.
Comment thread Lib/typing.py Outdated
Comment thread Lib/typing.py Outdated
@JelleZijlstra JelleZijlstra changed the title gh-149995: Update typing.py docstrings gh-149995: Update typing.py docstrings and documentation May 18, 2026
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 18, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32740384 | 📁 Comparing 270a6bf against main (f4cb79a)

  🔍 Preview build  

2 files changed
± library/typing.html
± whatsnew/changelog.html

Comment thread Lib/typing.py Outdated
Comment thread Lib/typing.py Outdated
JelleZijlstra and others added 2 commits May 18, 2026 08:38
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@JelleZijlstra JelleZijlstra added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants