-
Notifications
You must be signed in to change notification settings - Fork 37.7k
lint: Convert lint-include-guards.sh to Python #24902
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
lint: Convert lint-include-guards.sh to Python #24902
Conversation
Concept ACK Note that there is currently a linter error in the CI:
|
test/lint/lint-include-guards.py
Outdated
|
||
regex_pattern = f'#(ifndef|define|endif //) {header_id}' | ||
|
||
header_file_contents_string = open(header_file, 'r').read() |
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 prefer to open files using with
, it ensures that the file will be closed at the end of the operation.
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.
Good catch!
I tested ea3e7ab by commenting out the include guard in Before (
After ( If I delete (rather than comment out) the include guard, then it prints the correct message. |
Specify encoding when reading header files, add docstring Update test/lint/lint-include-guards.py include guard count logic Co-authored-by: Kevin Musgrave <tkm45@cornell.edu> Update test/lint/lint-include-guards.py by removing whitespace
3f9f09f
to
d5fdec5
Compare
Tested ACK d5fdec5 Outputs and exit codes match. Example:
|
Code review ACK d5fdec5 |
This PR addresses issue 24783. Converted lint-include-guards.sh to python.