Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] bpo-46769: Improve documentation for typing.TypeVar (GH-31712) #31941

Merged
merged 5 commits into from
Mar 23, 2022

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Mar 16, 2022

Co-authored-by: Jelle Zijlstra jelle.zijlstra@gmail.com
(cherry picked from commit 81b425d)

This PR backports GH-31712 to 3.10. However, two key modifications have been made:

  • References to reveal_type (new in 3.11) have been removed.
  • A new section, illustrating how to use bound TypeVars to annotate alternative-constructor classmethods, has been added. This is one of the most important uses of bound TypeVars for Python versions <=3.10, but is no longer needed in 3.11 due to the addition of typing.Self.

https://bugs.python.org/issue46769

…H-31712)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 81b425d)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood AlexWaygood changed the title [3.10] bpo-46769: Improve documentation for typing.TypeVar (GH-31712) [3.10] bpo-46769: Improve documentation for typing.TypeVar (GH-31712) Mar 16, 2022
@AlexWaygood AlexWaygood added docs Documentation in the Doc dir skip news needs backport to 3.9 only security fixes labels Mar 16, 2022
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks, good call on the additional example

@JelleZijlstra JelleZijlstra self-assigned this Mar 17, 2022
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Looks good! (Also cc @rhettinger since we're mentioning him in these docs.)

@miss-islington
Copy link
Contributor

Thanks @AlexWaygood for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @AlexWaygood and @JelleZijlstra, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker d5ed8a8258eaf7a241978b1b0aeb971108d0f7e0 3.9

JelleZijlstra pushed a commit to JelleZijlstra/cpython that referenced this pull request Mar 23, 2022
…ythonGH-31712) (pythonGH-31941)

* [3.10] bpo-46769: Improve documentation for `typing.TypeVar` (pythonGH-31712)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 81b425d)

* Remove references to `reveal_type`, add new section on `self` types.
(cherry picked from commit d5ed8a8)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@bedevere-bot
Copy link

GH-32067 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Mar 23, 2022
@AlexWaygood AlexWaygood deleted the backport-81b425d-3.10 branch March 23, 2022 05:02
ambv pushed a commit that referenced this pull request Mar 23, 2022
GH-31941) (GH-32067)

* [3.9] [3.10] bpo-46769: Improve documentation for `typing.TypeVar` (GH-31712) (GH-31941)

* [3.10] bpo-46769: Improve documentation for `typing.TypeVar` (GH-31712)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 81b425d)

* Remove references to `reveal_type`, add new section on `self` types.
(cherry picked from commit d5ed8a8)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

* remove unused susp allowlist

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…-31712) (pythonGH-31941) (pythonGH-32067)

* [3.9] [3.10] bpo-46769: Improve documentation for `typing.TypeVar` (pythonGH-31712) (pythonGH-31941)

* [3.10] bpo-46769: Improve documentation for `typing.TypeVar` (pythonGH-31712)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 81b425d)

* Remove references to `reveal_type`, add new section on `self` types.
(cherry picked from commit d5ed8a8)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

* remove unused susp allowlist

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants