Skip to content

PEP 835: Shorthand syntax for Annotated type metadata#4995

Open
till-varoquaux wants to merge 7 commits into
python:mainfrom
till-varoquaux:feature/at-type-annot
Open

PEP 835: Shorthand syntax for Annotated type metadata#4995
till-varoquaux wants to merge 7 commits into
python:mainfrom
till-varoquaux:feature/at-type-annot

Conversation

@till-varoquaux

@till-varoquaux till-varoquaux commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a draft PEP proposing a shorthand syntax for typing.Annotated using the @ operator (e.g., x: int @ "metadata" instead of typing.Annotated[int, "metadata"]).

This proposal aims to improve the developer ergonomics of metadata-heavy typing frameworks like Pydantic, FastAPI, and SQLModel, aligning Python's type annotations with the conciseness of JVM languages (Java, Kotlin).

All prototype implementations (CPython, Mypy, Pyright, Ruff) are complete and linked in the Reference Implementation section.

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
  • 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

@till-varoquaux till-varoquaux requested a review from a team as a code owner June 11, 2026 02:52
@till-varoquaux

Copy link
Copy Markdown
Contributor Author

@ilevkivskyi The draft is up and ready for your official sponsorship sign-off whenever you have a moment!

@read-the-docs-community

read-the-docs-community Bot commented Jun 11, 2026

Copy link
Copy Markdown

Documentation build overview

📚 pep-previews | 🛠️ Build #33130614 | 📁 Comparing ff2f302 against latest (0cc5e08)

  🔍 Preview build  

750 files changed · + 1 added · ± 749 modified

+ Added

± Modified

Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-0835.rst
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated

@ilevkivskyi ilevkivskyi left a comment

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.

The draft LG! But please take a look at comments by @JelleZijlstra

@till-varoquaux till-varoquaux force-pushed the feature/at-type-annot branch from b646aa7 to c237409 Compare June 12, 2026 03:02
@till-varoquaux

till-varoquaux commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks so much for the review and the help getting this staged, @JelleZijlstra and @ilevkivskyi !

Since my sponsor (@ilevkivskyi) has officially signed off on the draft, could one of the PEP editors go ahead and assign this an official PEP number?

Let me know if there is anything else needed from my end before we can get this merged and move the conversation over to Discourse.

@hugovk hugovk changed the title PEP 9999: Shorthand syntax for Annotated type metadata PEP 835: Shorthand syntax for Annotated type metadata Jun 12, 2026
@hugovk

hugovk commented Jun 12, 2026

Copy link
Copy Markdown
Member

Since my sponsor (@ilevkivskyi) has officially signed off on the draft, could one of the PEP editors go ahead and assign this an official PEP number?

Please use 835.

Comment thread peps/pep-0835.rst
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-0835.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
Comment thread peps/pep-9999.rst Outdated
@brianschubert brianschubert added the new-pep A new draft PEP submitted for initial review label Jun 12, 2026
@till-varoquaux

Copy link
Copy Markdown
Contributor Author

Thanks for the help, @hugovk! Really appreciate you sorting out the syntax highlighting,

The file rename is done, the CODEOWNERS file has been updated with Ivan as the sponsor.. Everything should be in order now.

@till-varoquaux till-varoquaux force-pushed the feature/at-type-annot branch from a3ddef4 to 9580655 Compare June 14, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-pep A new draft PEP submitted for initial review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants