Skip to content

Trim trailing whitespace#5406

Open
StanFromIreland wants to merge 1 commit into
pypy:mainfrom
StanFromIreland:trailig-whitespace
Open

Trim trailing whitespace#5406
StanFromIreland wants to merge 1 commit into
pypy:mainfrom
StanFromIreland:trailig-whitespace

Conversation

@StanFromIreland

Copy link
Copy Markdown
Member

This adds and runs the trailing-whitespace pre-commit hook, which well, trims trailing whitespace. There is quite a lot, across 500 files.


Thank you for contributing to PyPy. Please be sure to target one of our active branches:

  • main for pypy2.7, rpython, and documentation changes
  • py3.10 for the legacy python3.10 branch
  • py3.11 for the current development branch targeting python3.11

Do not target the branch/* branches, they are artifacts of our migration from mercurial to git.

@StanFromIreland StanFromIreland requested a review from mattip April 6, 2026 18:01
@mattip

mattip commented Apr 6, 2026

Copy link
Copy Markdown
Member

I'm not sure how to review this.

@StanFromIreland

Copy link
Copy Markdown
Member Author

Hmm, since these are all automatic fixes by the hook, if I were reviewing I’d just check it’s just mechanical changes (bar hook addition). I’d probably just run the hook locally and compare the local changes to the PRs.

@BarrensZeppelin

Copy link
Copy Markdown
Contributor

How about rolling back the changes and keeping the hook (which should only run on changed files)?

@StanFromIreland

Copy link
Copy Markdown
Member Author

IMO that just makes it a long term nuisance, touch some file and suddenly you have several unrelated changes, making many more PRs harder to review.

@mattip

mattip commented Apr 6, 2026

Copy link
Copy Markdown
Member

I don't trust the tools enough to blindly merge a huge change like this. Maybe break it into smaller pieces? Or only reformat files we are anyway touching?

@StanFromIreland

StanFromIreland commented Apr 6, 2026

Copy link
Copy Markdown
Member Author

I don't trust the tools enough to blindly merge a huge change like this

I’ve done far more with sed on prod servers;-) I see, I went through the diff (quite „efficiently,” but since the changes are so straightforward it’s easy to read), and I didn’t see any issues, I also can’t think of a way a something could be relying on trailing whitespace in a file, it’s not indentation after all.

Or only reformat files we are anyway touching?

My opinion on this: #5406 (comment)
In fact, in CPython we run pre-commit with —all-files in the CI. But, if you feel strongly about this path, I can update the PR and revert all the changes other than the hook.

# offset 0
s = """\
eb284000-eb285000 rw-p 00000000 00:00 0
eb284000-eb285000 rw-p 00000000 00:00 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am generally in favor of such changes. however this hunk shows the limits of just removing all trailing whitespace: removing trailing whitespace in a triple-quoted string is potentially quite wrong.




Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we must definitely exclude lib-python from these rules, we don't want merge conflicts with upstream stdlib changes due to whitespace stuff.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Upstream stdlib should not have any such trailing whitespace, there are CI checks for that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This PR only touches lib-python/2.7, I don't think that is updated?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants