Repository navigation
PEP 718: Address Discourse feedback and review comments - #5180
Conversation
- 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>
Documentation build overview
5 files changed ·
|
|
@Gobot1234 What do you think? |
Gobot1234
left a comment
There was a problem hiding this comment.
Had a read of this all seems good to me thanks for getting the last bit over the finish line @PabloRuizCuevas
Keep it; I'll work on adding it to the prototype. (Are there any others we missed?) |
gvanrossum
left a comment
There was a problem hiding this comment.
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 , glad you like it, yes let's hope it gets finally approved after such a long time :) |
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.
Main changes
__getitem__on functions doesn't validate and returns atypes.FunctionGenericAlias(#123).ParamSpec,TypeVarTupleexamples); unused type params count (#131); unsolvable params are reported at the call (#142); PEP 696 defaults per #121; error below Python 3.16.send()example); lambdas can't be generic; staticmethod and decorator rules (functools.wraps,@contextmanager).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.Tsketch dropped; blank lines fixed;foo_2split into.py/.pyi; plain assignment instead oftype 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.
PEP 123: Summary of changes)