-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
GH-109408: Move the C file whitespace check from patchcheck to pre-commit #109890
Changes from all commits
f7d8e99
25688d9
6e9040c
0e20e9f
b44f4c2
d4d31ff
b70cece
986f2a3
b15ef27
556978b
6891bdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,7 @@ def main(): | |
if optname == '-t': | ||
tabsize = int(optvalue) | ||
|
||
for filename in args: | ||
process(filename, tabsize) | ||
return max(process(filename, tabsize) for filename in args) | ||
|
||
|
||
def process(filename, tabsize, verbose=True): | ||
|
@@ -32,10 +31,10 @@ def process(filename, tabsize, verbose=True): | |
encoding = f.encoding | ||
except IOError as msg: | ||
print("%r: I/O error: %s" % (filename, msg)) | ||
return | ||
return 2 | ||
newtext = text.expandtabs(tabsize) | ||
if newtext == text: | ||
return | ||
return 0 | ||
backup = filename + "~" | ||
try: | ||
os.unlink(backup) | ||
|
@@ -49,7 +48,8 @@ def process(filename, tabsize, verbose=True): | |
f.write(newtext) | ||
if verbose: | ||
print(filename) | ||
return 1 | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
raise SystemExit(main()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I didn't realise! |
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:Both of those are matched by the
c
type, so this would be closer to parity:We do have half a dozen
.cpp
files in the codebase, do we want to expand to include them? Should we also addc++
fortrailing-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.
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.)