-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Infra: Add Sponsor to the PEPs API #4804
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
base: main
Are you sure you want to change the base?
Conversation
550a6c9 to
139ad22
Compare
c794e17 to
2680d2c
Compare
2680d2c to
8d14d70
Compare
johnslavik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Some thoughts.
| _frozen_ordered = dataclasses.dataclass(order=True, frozen=True) | ||
|
|
||
|
|
||
| @_frozen_ordered | ||
| class _Participant: | ||
| """Represent PEP participant.""" | ||
| full_name: str # The participant's name. | ||
| email: str # The participant's email address. | ||
|
|
||
|
|
||
| @_frozen_ordered | ||
| class _Author(_Participant): | ||
| """Represent PEP authors.""" | ||
| full_name: str # The author's name. | ||
| email: str # The author's email address. | ||
|
|
||
|
|
||
| @_frozen_ordered | ||
| class _Sponsor(_Participant): | ||
| """Represent PEP sponsors.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider not creating an alias here, obeying the locality of behavior rule (LoB) and keeping separate classes slightly more self-contained. Consider using dataclasses.field(doc=...).
| _frozen_ordered = dataclasses.dataclass(order=True, frozen=True) | |
| @_frozen_ordered | |
| class _Participant: | |
| """Represent PEP participant.""" | |
| full_name: str # The participant's name. | |
| email: str # The participant's email address. | |
| @_frozen_ordered | |
| class _Author(_Participant): | |
| """Represent PEP authors.""" | |
| full_name: str # The author's name. | |
| email: str # The author's email address. | |
| @_frozen_ordered | |
| class _Sponsor(_Participant): | |
| """Represent PEP sponsors.""" | |
| @dataclasses.dataclass(order=True, frozen=True) | |
| class _Participant: | |
| """Represent PEP participant.""" | |
| full_name: str = dataclasses.field(doc="The participant's name.") | |
| email: str = dataclasses.field(doc="The participant's email address.") | |
| @dataclasses.dataclass(order=True, frozen=True) | |
| class _Author(_Participant): | |
| """Represent PEP authors.""" | |
| full_name: str = dataclasses.field(doc="The author's name.") | |
| email: str = dataclasses.field(doc="The author's email address.") | |
| @dataclasses.dataclass(order=True, frozen=True) | |
| class _Sponsor(_Participant): | |
| """Represent PEP sponsors.""" |
|
|
||
|
|
||
|
|
||
| def _parse_author(data: str) -> list[_Author]: | ||
| """Return a list of author names and emails.""" | ||
| return [_Author(author, email) for author, email in _parse_participants(data)] | ||
|
|
||
| def _parse_sponsor(data: str) -> _Sponsor: | ||
| """Return sponsor name and email""" | ||
| return _Sponsor(*_parse_participants(data)[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting nits
| def _parse_author(data: str) -> list[_Author]: | |
| """Return a list of author names and emails.""" | |
| return [_Author(author, email) for author, email in _parse_participants(data)] | |
| def _parse_sponsor(data: str) -> _Sponsor: | |
| """Return sponsor name and email""" | |
| return _Sponsor(*_parse_participants(data)[0]) | |
| def _parse_author(data: str) -> list[_Author]: | |
| """Return a list of author names and emails.""" | |
| return [_Author(author, email) for author, email in _parse_participants(data)] | |
| def _parse_sponsor(data: str) -> _Sponsor: | |
| """Return sponsor name and email""" | |
| return _Sponsor(*_parse_participants(data)[0]) |
Adds Sponsor information to the PEP details, targeted mostly for API access
📚 Documentation preview 📚: https://pep-previews--4804.org.readthedocs.build/