Skip to content
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

Merged
merged 2 commits into from
Jan 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/python/qmk/cli/cformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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')]

Copy link
Member Author

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.

Copy link
Member

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.

if any(i in dirpath for i in ignores):
continue
Copy link
Member

@Erovia Erovia Jan 19, 2020

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) 


for name in filenames:
Expand Down