GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-109408: Add the docs whitespace check from patchcheck to pre-commit by hugovk · Pull Request #109854 · python/cpython

Conversation

@hugovk

@hugovk hugovk commented Sep 25, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Moves one of the patchcheck checks to pre-commit.

1.

patchcheck's normalize_docs_whitespace runs on files where fn.startswith('Doc') and fn.endswith(('.rst', '.inc')

pre-commit's trailing-whitespace is already running on c, python and rst in the whole codebase.

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

2.

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

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

3.

Remove docs_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 running make 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 of patchcheck.py: whitespace, f-strings, consistent pluralised outputs, fix typo.

  • Issue: Move Azure Pipelines CI to GitHub Actions #109408

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
hugovk added 6 commits September 25, 2023 18:39
@hugovk
Run pre-commit as part of 'make patchcheck'
dff437b
@hugovk
Use f-strings
97c6ccf
@hugovk
Add whitespace
029a9a4
@hugovk
Properly pluralise file(s), fix Unix typo
d7690a3
@hugovk
Remove normalize_docs_whitespace from patchcheck, it's covered by pre…
5cfcd19
…-commit's trailing-whitespace
@hugovk
Include inc files in pre-commit's trailing-whitespace
1eb8042
@hugovk
hugovk requested a review from AlexWaygood as a code owner September 25, 2023 15:52
@bedevere-app bedevere-app Bot added the awaiting review label Sep 25, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Sep 25, 2023
Move Azure Pipelines CI to GitHub Actions #109408
Closed
@hugovk hugovk added the skip news label Sep 25, 2023
AlexWaygood
AlexWaygood reviewed Sep 25, 2023
View reviewed changes
Comment thread Tools/patchcheck/patchcheck.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hugovk @AlexWaygood
Fix string
a85cd1c
Co-authored-by: Alex Waygood <[email protected]>
AlexWaygood
AlexWaygood approved these changes Sep 25, 2023
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Sep 25, 2023
AA-Turner
AA-Turner reviewed Sep 25, 2023
View reviewed changes
Comment thread Makefile.pre.in Outdated
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

@AA-Turner AA-Turner Sep 25, 2023

Copy link
Copy Markdown
Member

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.

I don't think make 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Sep 25, 2023

Copy link
Copy Markdown
Member Author

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.

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@AA-Turner AA-Turner Sep 26, 2023

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Sep 27, 2023

Copy link
Copy Markdown
Member Author

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.

I've removed the Makefile 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Tools/patchcheck/patchcheck.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/patchcheck/patchcheck.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/patchcheck/patchcheck.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

hugovk and others added 2 commits September 25, 2023 12:35
@hugovk @AA-Turner
Use "s" variable for readability
433153d
Co-authored-by: Adam Turner <[email protected]>
@hugovk
Reinstate docs_modified
a429344
AA-Turner
AA-Turner reviewed Sep 26, 2023
View reviewed changes
Comment thread Tools/patchcheck/patchcheck.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

sobolevn
sobolevn reviewed Sep 26, 2023
View reviewed changes

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

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.

Right now Makefile does not have pip mentions at all, I think that adding a new target with external deps needs a bit of discussion.
Since Makefile has a biiig range of different use-cases.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@hugovk @AA-Turner
Reinstate doc_files for docs_modified
63c6d17
Co-authored-by: Adam Turner <[email protected]>
@AA-Turner

AA-Turner commented Sep 26, 2023

Copy link
Copy Markdown
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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Sep 26, 2023
gh-109408: Run patchcheck in GitHub Actions #109459
Closed
gh-109408: Stop running patchcheck in CI #109895
Merged
@AlexWaygood

AlexWaygood commented Sep 26, 2023

Copy link
Copy Markdown
Member

We could perhaps create a poll on Discourse in the core development category asking how many people actually run make 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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner

AA-Turner commented Sep 26, 2023

Copy link
Copy Markdown
Member

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

A

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk
Revert makefile changes
05a5d35
@hugovk hugovk changed the title gh-109408: Docs: move trailing-whitespace from patchcheck to pre-commit gh-109408: Move the docs whitespace check from patchcheck to pre-commit Sep 27, 2023
@hugovk hugovk changed the title gh-109408: Move the docs whitespace check from patchcheck to pre-commit gh-109408: Add the docs whitespace check from patchcheck to pre-commit Oct 10, 2023
@hugovk
Merge branch 'main' into patchcheck-docs-whitespace
f4b16ec
@hugovk
hugovk enabled auto-merge (squash) October 10, 2023 07:45
@hugovk hugovk added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Oct 10, 2023
@hugovk
hugovk merged commit 7426ed0 into python:main Oct 10, 2023
@hugovk
hugovk deleted the patchcheck-docs-whitespace branch October 10, 2023 08:11
@miss-islington

miss-islington commented Oct 10, 2023

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Oct 10, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 10, 2023
@hugovk @AlexWaygood
@AA-Turner @miss-islington
pythongh-109408: Add the docs whitespace check from patchcheck to pre…
0175804
…-commit (pythonGH-109854)

(cherry picked from commit 7426ed0)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 10, 2023
@hugovk @AlexWaygood
@AA-Turner @miss-islington
pythongh-109408: Add the docs whitespace check from patchcheck to pre…
55d67b3
…-commit (pythonGH-109854)

(cherry picked from commit 7426ed0)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
@bedevere-app

bedevere-app Bot commented Oct 10, 2023

Copy link
Copy Markdown

GH-110594 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Oct 10, 2023
@bedevere-app

bedevere-app Bot commented Oct 10, 2023

Copy link
Copy Markdown

GH-110595 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Oct 10, 2023
@hugovk hugovk mentioned this pull request Oct 10, 2023
gh-107652: Fix CIFuzz build #110576
Merged
AlexWaygood added a commit that referenced this pull request Oct 10, 2023
@miss-islington @hugovk
@AlexWaygood @AA-Turner
[3.11] gh-109408: Add the docs whitespace check from patchcheck to pr…
d099def
…e-commit (GH-109854) (#110595)

gh-109408: Add the docs whitespace check from patchcheck to pre-commit (GH-109854)
(cherry picked from commit 7426ed0)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
AlexWaygood added a commit that referenced this pull request Oct 10, 2023
@miss-islington @hugovk
@AlexWaygood @AA-Turner
[3.12] gh-109408: Add the docs whitespace check from patchcheck to pr…
0ffbde4
…e-commit (GH-109854) (#110594)

gh-109408: Add the docs whitespace check from patchcheck to pre-commit (GH-109854)
(cherry picked from commit 7426ed0)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@hugovk @AlexWaygood
@AA-Turner @Glyphack
pythongh-109408: Add the docs whitespace check from patchcheck to pre…
a89e045
…-commit (python#109854)

Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sobolevn sobolevn sobolevn left review comments
@AA-Turner AA-Turner AA-Turner left review comments
@AlexWaygood AlexWaygood AlexWaygood approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@hugovk @AA-Turner @AlexWaygood @miss-islington @sobolevn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.