Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactorpeps.json logic into PEP class#2585

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 1 commit intopython:mainfromAA-Turner:json-refactor
Jun 8, 2022

Conversation

@AA-Turner
Copy link
Member

Factored out of#2579, simplifying the processing inpep_index_generator.py.

This also fixes a logic bug, as currently the author concatenation overwrites the.authors attribute with each author in turn, deleting the list.

A

@ghost
Copy link

ghost commentedMay 7, 2022
edited by ghost
Loading

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:
CLA not signed

@AA-TurnerAA-Turner self-assigned thisMay 7, 2022
@AA-TurnerAA-Turner added the infraCore infrastructure for building and rendering PEPs labelMay 7, 2022
@AA-Turner
Copy link
MemberAuthor

AA-Turner commentedMay 7, 2022
edited
Loading

I clicked through to sign the CLA with my GH username+ID email, and...

image

I'll try again in a few minutes.

A

AlexWaygood reacted with laugh emoji

@AA-Turner
Copy link
MemberAuthor

@hugovk how can we turn these comments off?

image

A

@hugovk
Copy link
Member

@hugovk how can we turn these comments off?

These are called "GitHub Checks":

https://docs.codecov.com/docs/github-checks

Let's try disabling by putting this in.github/codecov.yml:

github_checks:annotations:false
AA-Turner reacted with thumbs up emoji

Copy link
Member

@CAM-GerlachCAM-Gerlach left a comment

Choose a reason for hiding this comment

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

Seems like a solid change overall, and a step toward further single-sourcing PEP header parsing. I did have a few comments/suggestions, though.

AA-Turner reacted with heart emoji
Comment on lines +130 to +131
@property
deffull_details(self)->dict[str,str]:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@property
deffull_details(self)->dict[str,str]:
defto_dict(self)->dict[str,str]:

Instead of making this a property (especially when the otherwise similardetails, despite its name being a noun, is not), it would be clearer, more descriptive and conventional to have it be ato_dict() method, no?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I prefer the internal consistency of details / full_details, but not a big issue.

PEP.details will become a property under the refactoring work needed for subindices, I'm pretty sure, although again minor.

A

Copy link
Member

Choose a reason for hiding this comment

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

Well, I'm not sure why it needs to be a property, but that's really just bikeshedding. What confused me more was the "consistency" withdetails , as it doesn't seem obvious without careful inspection howfull_details differs from it, nor what callers should expect it to do.

However, that got me thinking: It would seem to me that there should only be one attribute (whether ametadata property, with the existing one made private or renamed toheaders, or ato_dict() method) that contains the PEP's metadata as a dict, and selecting specific attributes the caller wants to use and any specialized output-specific reformatting it needs it should be the callers concern, rather than the PEP class.

This shouldn't be that much to unify them; as it stands now,details is only used bypep_zero_generator.writer.column_format, which just passes it toformat(), and so the items it doesn't use are simply discarded. Otherwise, the only differences are:

  • number is missing fromfull_details, which should just be added
  • title is truncated indetails, which can be done by the caller or better yet just dropped (since many non-truncated titles and those with many authors already extend to two lines anyway, so the space may as well be used to just show the full title, since only one PEP title is longer than 79 characters which still fits easily on two lines)
  • type andstatus are truncated to one letter indetails, which can easily be done in the caller's format string, and is uppercased, which it already is for all valid types
  • status additionally has theApril Fool status normalized, which should be done for both

So the only changes needed to replacedetails withfull_details should be addingnumber, normalizing the April Fool status, and adding:.1 aftertype andstatus in thepep_zero_generator.writer.column_format format string.

Comment on lines +76 to +78
json_path=Path(app.outdir,"api","peps.json").resolve()
json_path.parent.mkdir(exist_ok=True)
json_path.write_text(create_pep_json(peps),encoding="utf-8")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I really understand the pressing need to rewrite all this when there were no functional changes in or near this line, and the previous form was perfectly valid and does exactly the same thing...it just seems like churn to me, but maybe I'm missing something important here.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

A (small) speed up as we only sort the large list of PEPs once.

A

Copy link
Member

Choose a reason for hiding this comment

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

I don't follow, sorry. Maybe I'm missing something, but I don't see how any of the changes here have anything to do with that, as no sorting is performed within this block andcreate_pep_json is called once both times in the same way

(Pedantic note: Other thancreate_pep_json() is not bound to a name first before using it, which saves a few hundred kB of memory for the few ≈milliseconds it is alive while the path is checked, and perhaps on the order of microseconds on the fast local name lookup.)

@hugovk
Copy link
Member

(Doing a close/re-open to trigger the CLA bot.)

@hugovkhugovk closed thisMay 20, 2022
@hugovkhugovk reopened thisMay 20, 2022
@hugovk
Copy link
Member

hugovk commentedJun 7, 2022
edited
Loading

(Doing a close/re-open to trigger the CLA bot. It was green onpython/cpython#93468 andpython/cpython#93564.)

hugovk reacted with confused emoji

@hugovkhugovk closed thisJun 7, 2022
@hugovkhugovk reopened thisJun 7, 2022
@AA-Turner
Copy link
MemberAuthor

AA-Turner commentedJun 7, 2022
edited
Loading

@hugovk Sadly I think that's as I was a co-author not the primary committer. (Which indicates that the CLA bot probably needs to be more thorough actually, I guess)

A

@AA-Turner
Copy link
MemberAuthor

@JelleZijlstra and this one too please!

A

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@CAM-GerlachCAM-GerlachCAM-Gerlach left review comments

Assignees

@AA-TurnerAA-Turner

Labels

infraCore infrastructure for building and rendering PEPs

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@AA-Turner@hugovk@CAM-Gerlach@JelleZijlstra

[8]ページ先頭

©2009-2025 Movatter.jp