Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jun 6, 2023

The current docs for typing.TypeAlias are pretty bare on what the advantages are for doing this:

X: TypeAlias = list[int]

Compared to this:

X = list[int]

I've added a motivating example in this PR.

While typing.TypeAlias is now deprecated following PEP-695, I think it's still worth improving the docs here. Lots of users won't be able to use the new syntax for a while, since it can't be backported to Python <3.12, and many users will want to continue supporting older Python versions for a while to come. Moreover, the fact that typing.TypeAliasType (the new mechanism introduce by PEP-695) has such a similar name is pretty confusing, in my opinion. It reinforces the need for us to have good documentation for both the new and the old symbol.


📚 Documentation preview 📚: https://cpython-previews--105372.org.readthedocs.build/

@AlexWaygood
Copy link
Member Author

@AlexWaygood AlexWaygood requested a review from JelleZijlstra June 7, 2023 08:12
@JelleZijlstra JelleZijlstra merged commit c5ec51e into python:main Jun 7, 2023
@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.11, 3.12.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 7, 2023
(cherry picked from commit c5ec51e)

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

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

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jun 7, 2023
@JelleZijlstra
Copy link
Member

I'll do the 3.11 backport

@AlexWaygood AlexWaygood deleted the TypeAlias-docs branch June 7, 2023 13:32
JelleZijlstra pushed a commit to JelleZijlstra/cpython that referenced this pull request Jun 7, 2023
(cherry picked from commit c5ec51e)

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

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

@bedevere-bot bedevere-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
Improve docs for `typing.TypeAlias` (GH-105372)
(cherry picked from commit c5ec51e)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
JelleZijlstra added a commit that referenced this pull request Jun 7, 2023
(cherry picked from commit c5ec51e)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants