-
-
Notifications
You must be signed in to change notification settings - Fork 40.6k
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
Align cformat rules with current CI implementation #7936
Conversation
lib/python/qmk/cli/cformat.py
Outdated
@@ -26,7 +26,8 @@ def cformat(cli): | |||
else: | |||
for dir in ['drivers', 'quantum', 'tests', 'tmk_core']: | |||
for dirpath, dirnames, filenames in os.walk(dir): | |||
if 'tmk_core/protocol/usb_hid' in dirpath: | |||
ignores = ['tmk_core/protocol/usb_hid', 'quantum/template'] |
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.
ignores = ['tmk_core/protocol/usb_hid', 'quantum/template'] |
I'd move this line out of the loops, right after else
and would use Path objects:
ignores = [Path('tmk_core/protocol/usb_hid'), Path('quantum/template')]
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.
Moved.
Not sure I like the mixture of Path and strings, and would prefer to defer it to another round of #7872.
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.
Well, you can use os.path
, something like if os.path.join(dirpath, dn) in ignores
.
But it's just me thinking about the code, you original code worked enough, with 7b97f2d it works better, so I'm cool with it.
lib/python/qmk/cli/cformat.py
Outdated
if any(i in dirpath for i in ignores): | ||
continue |
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.
Instead of skipping every dir/file individually, this will remove the ignorable(?) directory from the list and os.walk will not descend into it.
for dn in dirnames:
if Path(dirpath) / dn in ignores:
dirnames.remove(dn)
* Align cformat rules with current CI implementation * Optimise file walking
* Align cformat rules with current CI implementation * Optimise file walking
* Align cformat rules with current CI implementation * Optimise file walking
* Align cformat rules with current CI implementation * Optimise file walking
* Align cformat rules with current CI implementation * Optimise file walking
* Align cformat rules with current CI implementation * Optimise file walking
* Align cformat rules with current CI implementation * Optimise file walking
* Align cformat rules with current CI implementation * Optimise file walking
Description
Noticed while fixing #7934,
quantum/template/*
gets included in clang-format, which breaks the tokens#define MANUFACTURER % YOUR_NAME %
.Types of Changes
Checklist