Update generics reference to use PEP 695 type parameter syntax#2242
Update generics reference to use PEP 695 type parameter syntax#2242BHUVANSH855 wants to merge 5 commits into
Conversation
|
Thanks so far, but I also think the whole "Defining subclasses of generic classes" needs to be rewritten, as with Python 3.12 syntax, |
@srittau I made a few final refinements:
Everything should now consistently reflect the Python 3.12+ style. Kindly review it again. |
|
Just checking in regarding the latest updates to this PR. Thank you! |
|
Just checking in regarding the latest updates to this PR. Thank you! |
JelleZijlstra
left a comment
There was a problem hiding this comment.
There are lots of remaining places in the document using the old syntax. Look for all places that still use T = TypeVar("T")-style syntax and replace them.
|
Thanks for the review! @JelleZijlstra I’ve now updated the generics reference to consistently use the PEP 695 type parameter syntax in all applicable examples, including generic functions, methods, class methods, and bounded type parameters. I kept Please let me know if anything else should be refined. |
|
Hi @JelleZijlstra, Just checking in regarding the latest updates to this PR. Thank you! |
|
The document still has many old-style ParamSpec and TypeVar declarations further down. It also says "By default, all user-defined generics are invariant." which is no longer correct. |
Thanks for the review @JelleZijlstra, I’ve updated the invariance statement and added the missing imports in the variance examples. I also ensured formatting consistency in the code blocks. Please let me know if anything else needs adjustment. |
|
Please stop pinging on this PR. I'm a bit tired of it because of the number of times I've had to ask you to complete the change. I'll look at it when I find the time and energy; in the meantime please do not send any more pings. |
cc96f6e to
9731d54
Compare
This PR updates the
reference/generics.rstdocumentation to reflect the modern type parameter syntax introduced in PEP 695.Changes include:
Stack,Box) to useclass Foo[T]syntaxTypeVar/Genericto PEP 695This improves consistency with the spec documentation and reduces confusion for users of Python 3.12+.
Fixes #2227