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

bpo-46677: Add examples of inheritance and attributes to TypedDict docs. #31349

Merged
merged 15 commits into from
Mar 10, 2022

Conversation

CharlieZhao95
Copy link
Contributor

@CharlieZhao95 CharlieZhao95 commented Feb 15, 2022

Add examples of inheritance and attributes to TypedDict docs.

https://bugs.python.org/issue46677

Copy link
Contributor

@97littleleaf11 97littleleaf11 left a comment

Choose a reason for hiding this comment

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

I think it would be better to mention PEP655 in the doc!

@JelleZijlstra JelleZijlstra self-requested a review February 15, 2022 14:57
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! Some high-level feedback:

  • It would be good to use the formal syntax for these attributes, as we do with ParamSpec.args (https://docs.python.org/3.10/library/typing.html#typing.ParamSpec.args). That way, we can refer to the attribute definitions by name and find them more easily.
  • This is going to conflict with bpo-46066: Deprecate kwargs syntax for TypedDict definitions #31126. We should probably merge that one first as it got here first :)
  • Could you also mention that the functional syntax is useful for TypedDicts with keys that aren't valid identifiers?
  • We can't mention PEP 655 yet because the PEP is still in draft. In the meantime, we should mention the mixed inheritance trick to make a TypedDict with some required and non-required keys.

And cc @davidfstr in case you'd also like to give some feedback here.

@AlexWaygood AlexWaygood added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Mar 9, 2022
@JelleZijlstra JelleZijlstra self-assigned this Mar 9, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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! @gvanrossum I'm planning to merge this docs enhancement for TypedDict.

@JelleZijlstra JelleZijlstra merged commit 8a207e0 into python:main Mar 10, 2022
@miss-islington
Copy link
Contributor

Thanks @CharlieZhao95 for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington
Copy link
Contributor

Sorry @CharlieZhao95 and @JelleZijlstra, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 8a207e0321db75f3342692905e342f1d5e1add54 3.10

@miss-islington
Copy link
Contributor

Sorry, @CharlieZhao95 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 8a207e0321db75f3342692905e342f1d5e1add54 3.9

@JelleZijlstra
Copy link
Member

@CharlieZhao95 do you want to do the backports manually? Probably just need to fix some small conflicts.

@AlexWaygood AlexWaygood added needs backport to 3.10 only security fixes and removed needs backport to 3.10 only security fixes labels Mar 10, 2022
@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

Sorry @CharlieZhao95 and @JelleZijlstra, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 8a207e0321db75f3342692905e342f1d5e1add54 3.10

@CharlieZhao95
Copy link
Contributor Author

@CharlieZhao95 do you want to do the backports manually? Probably just need to fix some small conflicts.

Sure. It won't take long, I will finish it soon. 😉

CharlieZhao95 added a commit to CharlieZhao95/cpython that referenced this pull request Mar 11, 2022
…docs (pythonGH-31349)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 8a207e0)
@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Mar 11, 2022
@bedevere-bot
Copy link

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

CharlieZhao95 added a commit to CharlieZhao95/cpython that referenced this pull request Mar 11, 2022
…dDict` docs (pythonGH-31349)

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

Co-authored-by: Charlie Zhao <68189100+CharlieZhao95@users.noreply.github.com>
@bedevere-bot
Copy link

GH-31815 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Mar 11, 2022
JelleZijlstra pushed a commit that referenced this pull request Mar 12, 2022
…dDict` docs (GH-31349) (GH-31815)

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

Co-authored-by: Charlie Zhao <68189100+CharlieZhao95@users.noreply.github.com>
JelleZijlstra pushed a commit that referenced this pull request Mar 12, 2022
…Dict` docs. (GH-31349) (GH-31808)

* bpo-46677: Add examples of inheritance and attributes to `TypedDict` docs (GH-31349)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 8a207e0)
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…Dict` docs. (pythonGH-31349) (pythonGH-31808)

* bpo-46677: Add examples of inheritance and attributes to `TypedDict` docs (pythonGH-31349)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 8a207e0)
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.

10 participants