Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
GH-109408: Move the C file whitespace check from patchcheck to pre-commit#109890
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
AlexWaygood 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.
On the one hand, the patchcheck script will currently autofix this issue for you if run it locally, and it seems a shame to delete that functionality without adding it to pre-commit. On the other hand, I like having this check as part of pre-commit, and I also somewhat doubt that many people are trying to commit C source code that uses tabs in it into CPython -- so maybe the ability to autofix tabs isn't actually that useful after all.
AA-Turner commented Sep 26, 2023
We could change it to run A |
AlexWaygood commented Sep 26, 2023
I vote for the latter -- code golf is fun but pretty unmaintainable ;) |
AA-Turner commented Sep 26, 2023
Done, I've just reused A |
| if__name__=='__main__': | ||
| main() | ||
| raiseSystemExit(main()) |
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.
process() now has return values, which go to main(), but main() always returns None so we never get any errors here.
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.
Oh, I didn't realise! pre-commit was failing in my local testing when I introduced tabs, perhaps it just fails when a file is changed after the hook has run.
| name: "Check C file whitespace" | ||
| entry: "python Tools/patchcheck/untabify.py" | ||
| language: "system" | ||
| types_or: ['c', 'c++'] |
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.
We were running on .c and .h files before:
c_files= [fnforfninfile_pathsiffn.endswith(('.c', '.h'))]Both of those are matched by the c type, so this would be closer to parity:
| types_or: ['c', 'c++'] | |
| types_or: [c] |
We do have half a dozen .cpp files in the codebase, do we want to expand to include them? Should we also add c++ for trailing-whitespace above?
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.
The test passed with 'c++' included, I imagined that it was a previous oversight that they weren't included. I'll check if the trailing whitespace check also passes.
AA-TurnerSep 26, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp fails with 16 lines changed. Other than that all good (@zooba would you be alright with us enabling the trailing whitespace check here? No real views either way, if you'd prefer to keep the whitespace then that's the status quo anyway!)
A
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.
(We can always remove c++ later if needed.)
Uh oh!
There was an error while loading. Please reload this page.
| ifhas_c_files: | ||
| print("Did you run the test suite and check for refleaks?") | ||
| elifpython_files: | ||
| print("Did you run the test suite?") |
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.
It's so much clearer like this! 👍
Uh oh!
There was an error while loading. Please reload this page.
hugovk commented Oct 10, 2023
@AA-Turner Looks good, please could you resolve the conflict? |
hugovk 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!
miss-islington commented Oct 10, 2023
Thanks @AA-Turner for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
miss-islington commented Oct 10, 2023
Thanks @AA-Turner for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
miss-islington commented Oct 10, 2023
Sorry, @AA-Turner and @hugovk, I could not cleanly backport this to |
miss-islington commented Oct 10, 2023
Sorry, @AA-Turner and @hugovk, I could not cleanly backport this to |
…eck to pre-commit (pythonGH-109890) Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> (cherry picked from commit f5edb56) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
GH-110636 is a backport of this pull request to the 3.12 branch. |
…eck to pre-commit (pythonGH-109890) Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>. (cherry picked from commit f5edb56) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
GH-110640 is a backport of this pull request to the 3.11 branch. |
…pre-commit (python#109890) Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.