Error when using style argument in the form {key: value}
naubryGV opened this issue · comments
Because on how extend works on list in python, we can't use style argument like this:
"{BasedOnStyle: Microsoft,UseTab: Always,ColumnLimit: 180,Language: Cpp}"
A simple fix would be to change line 140 from:
if args.style:
invocation.extend(['--style', args.style])
to
if args.style:
invocation.extend(['--style=' + args.style])
Thanks
No issue on my side and the code looks OK to me as well.
Are you sure inline JSON cause any issue?
If so what issue?
When called from github actions, I got that issue. Not sure why then, I'll investigate.
I'm getting those errors:
run-clang-format.py: error: Command 'clang-format ./files/* "--style={BasedOnStyle: Microsoft, UseTab: Always, ColumnLimit: 180, Language: Cpp}"' returned non-zero exit status 1
YAML:1:2: error: Unknown value for BasedOnStyle: Microsoft
{BasedOnStyle: Microsoft, UseTab: Always, ColumnLimit: 180, Language: Cpp}
But even with the "fix" it doesn't work
Ok, I assume your escaping issue is not in run-clang-format.py but somewhere else in your Github Action.
Ok, sorry about that then. It really feels like my escaping was correct:
run-clang-format.py: error: Command 'clang-format ./files/test.cpp --style "{BasedOnStyle: Microsoft, UseTab: Always, ColumnLimit: 180, Language: Cpp}"' returned non-zero exit status 1
YAML:1:2: error: Unknown value for BasedOnStyle: Microsoft
{BasedOnStyle: Microsoft, UseTab: Always, ColumnLimit: 180, Language: Cpp}
^
Error parsing -style: Invalid argument
Maybe your clang-format version is too old and doesn't Microsoft style yet?
Does -style=Microsoft
work?
Why use -style
instead of .clang-format
?
It was the version! Thanks!
I would have to fetch a .clang-format file everytime from the repo, and as I'm only downloading the file changed by the PR, it felt easier to just pass the style as an argument.