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

gh-109408: Add the docs whitespace check from patchcheck to pre-commit#109854

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
hugovk merged 12 commits intopython:mainfromhugovk:patchcheck-docs-whitespace
Oct 10, 2023

Conversation

hugovk
Copy link
Member

@hugovkhugovk commentedSep 25, 2023
edited
Loading

Moves one of the patchcheck checks to pre-commit.

1.

patchcheck'snormalize_docs_whitespace runs on files wherefn.startswith('Doc') and fn.endswith(('.rst', '.inc')

pre-commit'strailing-whitespace is already running onc,python andrst in the whole codebase.

So this widens the check to coverinc files in the whole codebase, not just inDoc. I think this is a good thing.

2.

patchcheck substitutes matches ofre.compile(br'\s+(\r?\n)$') withbr'\1. That is, it strips multiple trailing\r and\n characters.

pre-commit'strailing-whitespace trims all trailing whitespace by default (docs). This also widens the check, I think this is a good thing.

3.

Removedocs_modified(doc_files) from patchcheck, it merely printed out whether any docs files were modified. I don't think it's useful now patcheck does no docs checking, and I'd like to eventually remove patchcheck.

4.

Some people might be still runningmake patchcheck? If so, to maintain some kind of parity, I've added steps to install and run pre-commit as part of the Makefile command.

We're doing a similar thing in the PEPs repo:

https://github.com/python/peps/blob/a159a9ac58ca73dc1da0b626b6df77807af455d0/Makefile#L62-L77

(And Pillow:https://github.com/python-pillow/Pillow/blob/main/Makefile)

Does this seem useful, or better to leave it out?

5.

Finally, some cleanup ofpatchcheck.py: whitespace, f-strings, consistent pluralised outputs, fix typo.

eendebakpt reacted with thumbs up emoji
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM (though I can't review the Makefile changes :)

Comment on lines 2775 to 2776
@$(RUNSHARED) ./$(BUILDPYTHON) -m pre_commit --version >/dev/null 2>&1 || $(RUNSHARED) ./$(BUILDPYTHON) -m pip install pre-commit >/dev/null 2>&1
$(RUNSHARED) ./$(BUILDPYTHON) -m pre_commit run --all-files
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 thinkmake patchcheck should run pre commit, especially if the goal is to remove it. Hence I'd say this is a docs point to communicate.

Suggested change
@$(RUNSHARED) ./$(BUILDPYTHON) -m pre_commit --version >/dev/null 2>&1 || $(RUNSHARED) ./$(BUILDPYTHON) -m pip install pre-commit >/dev/null 2>&1
$(RUNSHARED) ./$(BUILDPYTHON) -m pre_commit run --all-files

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm thinking it would be a good idea to add amake lint target like we have for the PEPs repo (and Pillow), which seems to work there.

Perhaps we should addmake lint now and have it run pre-commit; and maybe also patchcheck?

AA-Turner reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I'd agree. We should also update the devguide (currently onlypatchcheck is mentioned)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I've removed theMakefile changes from this PR, let's decide what to later after discussion:

https://discuss.python.org/t/do-you-use-make-patchcheck/34743?u=hugovk

hugovkand others added2 commitsSeptember 25, 2023 12:35
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

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

Right nowMakefile does not havepip mentions at all, I think that adding a new target with external deps needs a bit of discussion.
SinceMakefile has a biiig range of different use-cases.

In my opinion havingpre-commit CLI and in CI on its own is good enough.

AA-Turner reacted with thumbs up emoji
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@AA-Turner
Copy link
Member

Perhaps we should add make lint
In my opinion having pre-commit CLI and in CI on its own is good enough.

To clarify my opinion: I don't mind which of either of these are used, as I use Windows so the choice is personally irrelevant! I'll be happy with whatever Hugo goes for.

A

@AlexWaygood
Copy link
Member

We could perhaps create a poll on Discourse in the core development category asking how many people actually runmake patchcheck. If the answer is zero (or very few), then that simplifies the decisions that need to be here — we can just get rid of it from the Makefile

@AA-Turner
Copy link
Member

Written up some questions athttps://discuss.python.org/t/do-you-use-make-patchcheck/34743

A

hugovk reacted with thumbs up emoji

@hugovkhugovk changed the titlegh-109408: Docs: move trailing-whitespace from patchcheck to pre-commitgh-109408: Move the docs whitespace check from patchcheck to pre-commitSep 27, 2023
@hugovkhugovk changed the titlegh-109408: Move the docs whitespace check from patchcheck to pre-commitgh-109408: Add the docs whitespace check from patchcheck to pre-commitOct 10, 2023
@hugovkhugovkenabled auto-merge (squash)October 10, 2023 07:45
@hugovkhugovk added needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsOct 10, 2023
@hugovkhugovk merged commit7426ed0 intopython:mainOct 10, 2023
@hugovkhugovk deleted the patchcheck-docs-whitespace branchOctober 10, 2023 08:11
@miss-islington
Copy link
Contributor

Thanks@hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestOct 10, 2023
…-commit (pythonGH-109854)(cherry picked from commit7426ed0)Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestOct 10, 2023
…-commit (pythonGH-109854)(cherry picked from commit7426ed0)Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@bedevere-app
Copy link

GH-110594 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelOct 10, 2023
@bedevere-app
Copy link

GH-110595 is a backport of this pull request to the3.11 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.11only security fixes labelOct 10, 2023
AlexWaygood added a commit that referenced this pull requestOct 10, 2023
…e-commit (GH-109854) (#110595)gh-109408: Add the docs whitespace check from patchcheck to pre-commit (GH-109854)(cherry picked from commit7426ed0)Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
AlexWaygood added a commit that referenced this pull requestOct 10, 2023
…e-commit (GH-109854) (#110594)gh-109408: Add the docs whitespace check from patchcheck to pre-commit (GH-109854)(cherry picked from commit7426ed0)Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
…-commit (python#109854)Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sobolevnsobolevnsobolevn left review comments

@AA-TurnerAA-TurnerAA-Turner left review comments

@AlexWaygoodAlexWaygoodAlexWaygood approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@hugovk@AA-Turner@AlexWaygood@miss-islington@sobolevn

[8]ページ先頭

©2009-2025 Movatter.jp