FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

PEP 718: Address Discourse feedback and review comments by PabloRuizCuevas · Pull Request #5180 · python/peps · GitHub

Repository navigation

PEP 718: Address Discourse feedback and review comments - #5180

Merged
gvanrossum merged 1 commit into
python:mainfrom
PabloRuizCuevas:pep-718-discourse-points
Oct 21, 2026
Merged

gvanrossum merged 1 commit into
python:mainfrom
PabloRuizCuevas:pep-718-discourse-points

Conversation

PabloRuizCuevas commented Oct 20, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

This updates PEP 718 to answer the open points from the Discourse thread (mainly @carljm's review) and @gvanrossum's comments on @Gobot1234's commit 14882ca. It ports parts of that commit; James is credited as co-author.

A note on methodology. I used an LLM to summarise every pending technical question from the Discourse thread and Guido's review of James's commit, and turned them into a questionnaire that I answered myself: all questions, options and my decisions. The decisions are mine, aligned with the original proposal and with Guido's, Carl's and other core devs' input; where core devs disagreed, I picked what felt most natural. The LLM then helped write them into the PEP, and I checked the result. It's a draft and I'll do a full cleanup pass soon, so if parts read a bit LLM-like, the decisions behind them are human, not unread slop.

Main changes

  • Runtime: __getitem__ on functions doesn't validate and returns a types.FunctionGenericAlias (#123).
  • Callable values: checkers allow subscribing any value with a generic callable type (the lenient prototype); the strict variant goes to Rejected Ideas.
  • Type checking: same rules as generic classes (ParamSpec, TypeVarTuple examples); unused type params count (#131); unsolvable params are reported at the call (#142); PEP 696 defaults per #121; error below Python 3.16.
  • Overloads: a subscription applies to each overload, following the mypy prototype.
  • Kinds of functions: generators and async functions are subscriptable (with a send() example); lambdas can't be generic; staticmethod and decorator rules (functools.wraps, @contextmanager).
  • New sections: Use Cases, Runtime Performance, Backwards Compatibility, Rejected Ideas, Deferred Ideas (reification, generic lambdas).
  • Other: Motivation workarounds fixed, reference implementation links updated, Python-Version: 3.16.

Guido's comments on 14882ca

All 11 addressed: quotes around "function objects"; reification moved to Deferred Ideas; "requested many times" softened; Foo[int]() output shown; class-only examples removed; current runtime error shown; "roots of runtime type checking" and the .T sketch dropped; blank lines fixed; foo_2 split into .py/.pyi; plain assignment instead of type X = foo_1[int].

Open question (@gvanrossum)

The spec lists types.MethodWrapperType (e.g. object().__str__) as subscriptable, but python/cpython#156201 doesn't cover it. Keep it and add support there, or drop it from the spec? The text keeps it for now.

Follow-up PR

A Motivation rewrite with real-world examples; How to Teach This and Security Implications.


  • Change is either:
    • To a Draft PEP
    • To an Accepted or Final PEP, with Steering Council approval
    • To fix an editorial issue (markup, typo, link, header, etc)
  • PR title prefixed with PEP number (e.g. PEP 123: Summary of changes)

- Specify that the runtime __getitem__ does not validate subscriptions,
  and return a new types.FunctionGenericAlias subclass
- Type checking rules: same as generic classes (ParamSpec, TypeVarTuple,
  *tuple for a single TypeVarTuple), unused and unsolvable type
  parameters, PEP 696 defaults, generic Callable values, version gating
- Overloads: per-overload filtering from the mypy prototype, and a
  consistency rule for the implementation's type parameters
- Add Use Cases, Runtime Performance (with measurements), Rejected Ideas
  and Deferred Ideas; move reification to Deferred Ideas
- Fix the motivation workarounds and examples, link the reference
  implementations, Python-Version 3.16

Co-authored-by: James Hilton-Balfe <gobot1234yt@gmail.com>

python-cla-bot Bot commented Oct 20, 2026 •
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Copy link
Copy Markdown

Documentation build overview

📚 pep-previews | 🛠️ Build #35257724 | 📁 Comparing 6a45553 against latest (d5d2571)

  🔍 Preview build  

5 files changed · ± 5 modified

± Modified

Copy link
Copy Markdown
Member

@Gobot1234 What do you think?

Gobot1234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Had a read of this all seems good to me thanks for getting the last bit over the finish line @PabloRuizCuevas

Copy link
Copy Markdown
Member

The spec lists types.MethodWrapperType (e.g. object().__str__) as subscriptable, but python/cpython#156201 doesn't cover it. Keep it and add support there, or drop it from the spec? The text keeps it for now.

Keep it; I'll work on adding it to the prototype. (Are there any others we missed?)

gvanrossum 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you Pablo for this tremendous upgrade, and for making your use of LLMs transparent! I like your approach to asking the LLM to present choices that you personally decide. (I've used something simpler occasionally by asking an LLM to summarize the remaining controversies in a discourse thread, but yours is more useful still!)

I am approving and merging this and announce the new version (after 3 years!) to the thread. I have some questions and feedback that I will ask separately after that's done.

There are also still some objections from Jelle and Carl to be dealt with (but there's hope).

gvanrossum marked this pull request as ready for review October 20, 2026 21:32
gvanrossum enabled auto-merge (squash) October 20, 2026 21:45
gvanrossum merged commit 81c3b6a into python:main Oct 21, 2026
5 checks passed

Copy link
Copy Markdown
Contributor Author

@gvanrossum , glad you like it, yes let's hope it gets finally approved after such a long time :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL