-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
typing: Improve documentation of generic classes and aliases #105369
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
Conversation
Doc/library/typing.rst
Outdated
def second(l: Sequence[U]) -> U: # Function is generic around the TypeVar "U" | ||
return l[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it was slightly confusing to have two functions named first
in two adjacent code examples
Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
Sorry, @AlexWaygood, I could not cleanly backport this to |
…H-105369) (cherry picked from commit d63a7c3) Co-authored-by: Alex Waygood <[email protected]>
GH-105453 is a backport of this pull request to the 3.12 branch. |
GH-105454 is a backport of this pull request to the 3.11 branch. |
…H-105369) (#105453) typing: Improve documentation of generic classes and aliases (GH-105369) (cherry picked from commit d63a7c3) Co-authored-by: Alex Waygood <[email protected]>
The documentation for
typing.Dict
currently describes the alias as:In 2023, this is pretty misleading: it implies that
dict
is not generic, and that you have to usetyping.Dict
if you want to supply type parameters. There are similar issues across the typing documentation for the various aliases that were deprecated as part of PEP-585.This PR also makes a few related edits to the docs for generic classes, which look like they still have some pre-PEP-585 language in them.
📚 Documentation preview 📚: https://cpython-previews--105369.org.readthedocs.build/