Skip to content

PEP 846: Docstrings for type aliases - #5116

Draft
johnslavik wants to merge 3 commits into
python:mainfrom
johnslavik:ta-docstrings
Draft

PEP 846: Docstrings for type aliases#5116
johnslavik wants to merge 3 commits into
python:mainfrom
johnslavik:ta-docstrings

Conversation

@johnslavik

@johnslavik johnslavik commented Sep 7, 2026

Copy link
Copy Markdown
Member

I've just started the work on the PEP, hence a draft PR to book the number.

PR template checkboxes

Basic requirements (all PEP Types)

  • Read and followed PEP 1 & PEP 12
  • File created from the latest PEP template
  • PEP has next available number, & set in filename (pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) and PEP header
    • Tip: find the next available number with pepotron — run uvx pepotron next (or pipx install pepotron then pep next)
  • Title clearly, accurately and concisely describes the content in 79 characters or less
  • Core dev/PEP editor listed as Author or Sponsor, and formally confirmed their approval
  • Author, Status (Draft), Type and Created headers filled out correctly
  • PEP-Delegate, Topic, Requires and Replaces headers completed if appropriate
  • Required sections included
    • Abstract (first section)
    • Copyright (last section; exact wording from template required)
  • Code is well-formatted (PEP 7/PEP 8) and is in code blocks, with the right lexer names if non-Python
  • PEP builds with no warnings, pre-commit checks pass and content displays as intended in the rendered HTML
  • Authors/sponsor added to .github/CODEOWNERS for the PEP

Standards Track requirements

  • PEP topic discussed in a suitable venue with general agreement that a PEP is appropriate
  • Suggested sections included (unless not applicable)
    • Motivation
    • Specification
    • Rationale
    • Backwards Compatibility
    • Security Implications
    • How to Teach This
    • Reference Implementation
    • Rejected Ideas
    • Open Issues
    • Acknowledgements
    • Footnotes
    • Change History
  • Python-Version set to valid (pre-beta) future Python version, if relevant
  • Any project stated in the PEP as supporting/endorsing/benefiting from the PEP formally confirmed such
  • Right before or after initial merging, PEP discussion thread created and linked to in Discussions-To and Post-History

@johnslavik johnslavik changed the title PEP 846: Draft runtime docstrings for type aliases PEP 846: Docstrings for type aliases Sep 7, 2026
@read-the-docs-community

read-the-docs-community Bot commented Sep 7, 2026

Copy link
Copy Markdown

Documentation build overview

📚 pep-previews | 🛠️ Build #34430764 | 📁 Comparing fbd7b8a against latest (24419b9)

  🔍 Preview build  

5 files changed · + 1 added · ± 4 modified

+ Added

± Modified

@johnslavik johnslavik self-assigned this Sep 7, 2026
Comment thread peps/pep-0846.rst
:py:keyword:`type` statements and makes the first following docstring
available at runtime.

If the next statement after a :py:keyword:`type` statement in the same suite is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth saying explicitly that there may be comments and blank lines between the type statement and its docstring?

Comment thread peps/pep-0846.rst Outdated
Comment thread peps/pep-0846.rst
used by inspection tools rather than compilation.

The attribute can be assigned to after creation. Deleting it resets it to
``None``. The :py:class:`~typing.TypeAliasType` constructor does not gain a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?

@johnslavik johnslavik Sep 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure.

dataclasses.field(doc=...) is a good precedent, the API will be more convenient.

I've changed my mind, I'll add the new parameter.

Comment thread peps/pep-0846.rst
Discussions-To: Pending
Status: Draft
Type: Standards Track
Topic: Typing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Topic: Typing, but there's nothing for type checkers to do. I can't really think of much type checkers could do with this PEP; maybe they could have some verbose diagnostics mode that shows alias docstrings, but that's not something the PEP should prescribe.

I guess this Topic implies that the Typing Council should opine on this PEP. And maybe there should be a line making it explicit that no changes in type checker behavior are expected.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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.

2 participants