mikr/whatstyle

AttributeError: 'str' object has no attribute 'keys'

seanm opened this issue · 3 comments

seanm commented

I downloaded master just now and tried with a .c and .cxx file, in both cases I get this output. Maybe my clang is too new?

$ python whatstyle.py -f clang-format test.c 
-----------------------
Running whatstyle 0.1.4
Using formatter /Users/sean/llvm/llvm-rel-install/bin/clang-format (clang-format version 6.0.0 (trunk 315610))
Using this for comparing files: /usr/bin/python -u whatstyle.py --stdindiff -- #FILENAME#
Traceback (most recent call last):
  File "whatstyle.py", line 7140, in <module>
    sys.exit(main())
  File "whatstyle.py", line 7131, in main
    return run_with_args(args, parser)
  File "whatstyle.py", line 7110, in run_with_args
    ret = whatstyle(args, parser)
  File "whatstyle.py", line 6689, in whatstyle
    formatter.register_options()
  File "whatstyle.py", line 1895, in register_options
    self.register_options_from_dump(dump)
  File "whatstyle.py", line 1899, in register_options_from_dump
    version, styledef = find_closest_clang_version(unistr(config_dump))
  File "whatstyle.py", line 6006, in find_closest_clang_version
    dumpstylenames = set(dump_options.keys())
AttributeError: 'str' object has no attribute 'keys'

I'm using Python 2.7.10 that comes with macOS 10.12.6.

mikr commented

Indeed, for the first time in version 6.0 clang-format uses standard YAML lists that the built-in YAML parser did not handle.
I corrected this problem and also added the new format options for clang-format 6.0dev as well.
Please let me know if the new version works for you, thanks!

seanm commented

Thanks for fixing so quickly. It works now. I do see this warning though:

Warning: We don't know about the option 'BreakConstructorInitializersBeforeComma' that your clang-format supports.
... but it looks like a bool type and we might as well tweak it.
mikr commented

BreakConstructorInitializersBeforeComma has been replaced by a
BreakConstructorInitializers option and is now only supported for backward compatibility,
see lib/Format/Format.cpp and unittests/Format/FormatTest.cpp.
In this deprecation case it would have been better for whatstyle not to use this option
but if you some day you use a future clang-format version, you would benefit because
whatstyle makes use of every boolean option even when it is unknown, the proper
thing in either case is to inform you about it with a warning.