Skip to content

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

Merged
JelleZijlstra merged 7 commits into
python:mainfrom
JelleZijlstra:typingdocstrings
May 22, 2026
Merged

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

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented May 18, 2026

Copy link
Copy Markdown
Member

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

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

Copy link
Copy Markdown

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
@JelleZijlstra JelleZijlstra merged commit f159419 into python:main May 22, 2026
58 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @JelleZijlstra, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f159419ae2ef1aebbd90ce9427b55e27738c960c 3.14

@bedevere-app

bedevere-app Bot commented May 22, 2026

Copy link
Copy Markdown

GH-150215 is a backport of this pull request to the 3.15 branch.

@miss-islington-app

Copy link
Copy Markdown

Sorry, @JelleZijlstra, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f159419ae2ef1aebbd90ce9427b55e27738c960c 3.13

JelleZijlstra added a commit that referenced this pull request May 22, 2026
)

[3.14] gh-149995: Update typing.py docstrings and documentation (GH-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.
(cherry picked from commit f159419)
JelleZijlstra added a commit that referenced this pull request May 22, 2026
…49996) (#150215)

gh-149995: Update typing.py docstrings and documentation (GH-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.
(cherry picked from commit f159419)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
grantlouisherman pushed a commit to grantlouisherman/cpython that referenced this pull request May 22, 2026
…n#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.
grantlouisherman pushed a commit to grantlouisherman/cpython that referenced this pull request May 22, 2026
…n#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.
@serhiy-storchaka

Copy link
Copy Markdown
Member

Please don't forget about backports.

@JelleZijlstra

Copy link
Copy Markdown
Member Author

Looks like this was backported (#150216, #150217), but the backports were not linked here.

@JelleZijlstra JelleZijlstra removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jul 15, 2026
@AlexWaygood

Copy link
Copy Markdown
Member

Bedevere must have been having a bad day

@JelleZijlstra JelleZijlstra deleted the typingdocstrings branch July 15, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants