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

PEP 655: Marking individual TypedDict items as required #1829

Merged
merged 10 commits into from
Feb 26, 2021

Conversation

davidfstr
Copy link
Contributor

...or potentially missing

@the-knights-who-say-ni

This comment has been minimized.

@gvanrossum
Copy link
Member

FYI please use PEP number 655 (rename the file and change the pep number field).

pep-0999.rst Outdated Show resolved Hide resolved
pep-0999.rst Outdated Show resolved Hide resolved
pep-0999.rst Outdated Show resolved Hide resolved
pep-0999.rst Outdated Show resolved Hide resolved
@davidfstr davidfstr changed the title PEP 999: Marking individual TypedDict items as required PEP 655: Marking individual TypedDict items as required Feb 24, 2021
@davidfstr
Copy link
Contributor Author

First round of comments has been integrated. Ready for another round of review.

@davidfstr
Copy link
Contributor Author

Oi. I just realized I linked to my TypeForm mypy issue when this is the Required PEP. Working on too many PEPs at once...

Let me just rewrite that reference...

@davidfstr
Copy link
Contributor Author

Okay. Actually ready for code review again. ✨

@gvanrossum
Copy link
Member

Since you apparently used git push -f, I can’t easily compare what you changed since my review, so I’ll just assume you addressed everything. :-)

However, I feel the PEP is pretty repetitive, with (almost) the same being said several times. That makes it look formal but not easy to read. Can you think of ways to improve this?

@davidfstr
Copy link
Contributor Author

Since you apparently used git push -f, I can’t easily compare what you changed since my review, so I’ll just assume you addressed everything. :-)

I'll add incremental commits next time :-) Can always squash before commit.

I feel the PEP is pretty repetitive, with (almost) the same being said several times.

If it's a concern about length, the longest sections are {How to Teach This, Rejected Ideas}:

  • "How to Teach This" in particular is meant as a standalone tutorial on how to use the syntax, so it certainly repeats some content from other sections. This section I think was most important when we only had Required (lacking NotRequired) and so I felt it necessary to explain the gymnastics with total=False that were necessary to selectively mark keys as not required. But now there's less need for a tutorial with NotRequired being directly spellable. I could see removing this section, perhaps integrating the guidance of preferring X|Y form when using Required[] elsewhere. ⭐

  • "Rejected Ideas" is long because there were a lot of rejected ideas. :)


"Motivation", "Rationale", and "Specification" - which form the meat of the PEP - are each a handful of paragraphs when you ignore the illustrative code snippets. Not entirely clear what I can cut without losing content.

The most common example of a TypedDict I used (Movie) has 4 keys, and appears 8 times. Could reduce it to just 2 keys - one required and one potentially missing. What do you think? ⭐


Perhaps you could give specific examples of some items you found repetitive?

@gvanrossum
Copy link
Member

gvanrossum commented Feb 25, 2021 via email

@davidfstr
Copy link
Contributor Author

davidfstr commented Feb 26, 2021

Thanks for taking the time to provide more detailed feedback! Definitely applying the "less is more" principle in this latest revision. :)

I did remove the restriction disallowing Required[] and NotRequired[] in redundant locations, since I agree that think there may be some folks who want to be explicit about requiredness for all keys.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for shortening the main text quite a bit from the first revision! I'll merge now and then you can post to typing-sig again (and send a tiny PR with an updated post-history).

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

Successfully merging this pull request may close these issues.

3 participants