Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygoodAlexWaygood commented Jun 6, 2023

The documentation for typing.Dict currently describes the alias as:

A generic version of :class:dict.

In 2023, this is pretty misleading: it implies that dict is not generic, and that you have to use typing.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/

Comment on lines 322 to 323
def second(l: Sequence[U]) -> U: # Function is generic around the TypeVar "U"
return l[1]
Copy link
MemberAuthor

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

@AlexWaygoodAlexWaygood changed the title typing: Improve documentation of generic classestyping: Improve documentation of generic classes and aliasesJun 6, 2023
@AlexWaygood
Copy link
MemberAuthor

@miss-islington
Copy link
Contributor

Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @AlexWaygood, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker d63a7c3694d5c4484fcaa01c33590b1d4bc2559e 3.11

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 7, 2023
…H-105369) (cherry picked from commit d63a7c3) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@bedevere-bot
Copy link

GH-105453 is a backport of this pull request to the 3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12 only security fixes label Jun 7, 2023
@AlexWaygoodAlexWaygood deleted the deprecated-aliases branch June 7, 2023 14:03
@bedevere-bot
Copy link

GH-105454 is a backport of this pull request to the 3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11 only security fixes label Jun 7, 2023
AlexWaygood added a commit that referenced this pull request Jun 7, 2023
…H-105369) (#105453) typing: Improve documentation of generic classes and aliases (GH-105369) (cherry picked from commit d63a7c3) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip issueskip newstopic-typing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@AlexWaygood@miss-islington@bedevere-bot@JelleZijlstra