PEP 835 Update: Spec Alignment, Format.TYPE, and Rendered Draft
Thank you all for the extensive stress-testing and feedback over the last few weeks. The discussion here has been very useful to refine this PEP.
I’ve just pushed a major update to the draft in my personal fork. I’m waiting a bit before upstreaming the changes to gather more feedback. You can read the fully rendered version here, as well as the diff.
Summary of Changes
-
Terminology & Spec Alignment: Consolidated terminology to provide clear definitions for the concepts used throughout the PEP (Type Expression, Type Metadata, Non-Typing Annotation, Symbol Decorator) and align better with the typing spec. This clarifies that
@is strictly scoped to Type Expressions. -
Forward References &
None: Clarified that the newly introducedFormat.TYPEhandlesNone @Metadatastructurally. This eliminates the need to modifyNoneType.__matmul__, keeping standard runtime execution perfectly safe. The “Supporting None” open issue has been removed. -
Future Work: Added extensive examples of how this syntax perfectly maps to potential future Symbol Decorators (e.g., annotating parameters/fields directly). Also added a JSR-308 inspired proposal for PEP 746, demonstrating how intersection types (
&) could enforce target-based constraints for metadata. -
Structure & Formatting: Reordered all sections to strictly comply with the PEP 1 template and added the mandatory “Security Implications” section.
-
Rejected Ideas: Expanded to address the alternative syntaxes discussed in this thread (e.g.,
<@, brackets, soft keywords) and moved the__rmatmul__rationale here.
A Note on Thread Context and Feedback
This thread has been fantastic for catching edge cases. Just a heads up: to keep the document focused, I’ve centered it strictly on the canonical design rather than listing every alternative we’ve covered.
If you spot a critical technical flaw I’ve missed, please feel free to DM me. I also want to leave my inbox open to maintainers of type checkers (Mypy, Pyright, ty, pyrefly…) and libraries (Pydantic, FastAPI, cattrs, msgspec…) or anyone who might prefer to discuss implementation details outside the busy public thread.
Thanks again to everyone who has helped shape this proposal!