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

Make a top-level TypedDict page #14584

Merged
merged 1 commit into from
Feb 2, 2023
Merged

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Feb 2, 2023

This just moves content around (with minimal editing to make the moves make sense).

TypedDict has been the target for several features, including some that are not yet documented. There was another PEP drafted today that was TypedDict themed. It's also pretty popular with users.

Linking #13681

This just moves content around.

TypedDict has been the target for several features, including some that
are not yet documented. There was another PEP drafted today that was
TypedDict themed. It's also pretty popular with users.
@tmke8
Copy link
Contributor

tmke8 commented Feb 2, 2023

Maybe the class-based syntax should be introduced before the functional syntax? It seems to me the class-based syntax is nowadays preferred. I only see the functional syntax recommended when a key is not a valid variable name (e.g., it contains a hyphen or it coincides with a reserved keyword).

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.

I agree with the feedback that we should focus on the class-based syntax, and mention the functional syntax only as an alternative for rare cases. However, that might be better done in a separate PR, leaving this one focused on the move.

Other feedback:

  • Consider using :py:data: to link to the stdlib docs, like we do for NewType.
  • Do we have a general stance on when to use typing_extensions imports in the docs? TypedDict has been in the stdlib since 3.8.

@hauntsaninja hauntsaninja merged commit 3f13939 into python:master Feb 2, 2023
@hauntsaninja hauntsaninja deleted the docs5 branch February 2, 2023 19:55
@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Feb 2, 2023

Thanks, will make actual edits in a separate PR.

Do we have a general stance on when to use typing_extensions

I don't think we do. My views:

  • 3.7 is close enough to EOL that I don't mind having random snippets in examples assume 3.8. I'm doing a big docs editing pass now, I may as well save us some time in four months (we may still want to support 3.7 for a little longer, but we don't need to target our educational material at those users)
  • We should still have typing_extensions documented in places that it's helpful, it just doesn't necessarily need to be every snippet
  • We should also improve the error message mypy gives when imports are missing from typing

@hauntsaninja
Copy link
Collaborator Author

PR for the suggestion here: #14591

hauntsaninja added a commit that referenced this pull request Feb 3, 2023
This just moves content around (with minimal editing to make the moves
make sense).

TypedDict has been the target for several features, including some that
are not yet documented. There was another PEP drafted today that was
TypedDict themed. It's also pretty popular with users.

Linking #13681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants