cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
958 stars 105 forks source link

Error dumping config in YAML format #192

Closed dandrestor closed 4 years ago

dandrestor commented 4 years ago
$ cmake-format --dump-config yaml
Traceback (most recent call last):
  File "/home/dan/.local/bin/cmake-format", line 11, in <module>
    sys.exit(main())
  File "/home/dan/.local/lib/python2.7/site-packages/cmake_format/__main__.py", line 570, in main
    return inner_main()
  File "/home/dan/.local/lib/python2.7/site-packages/cmake_format/__main__.py", line 468, in inner_main
    dump_config(args, config_dict, sys.stdout)
  File "/home/dan/.local/lib/python2.7/site-packages/cmake_format/__main__.py", line 358, in dump_config
    default_flow_style=False, sort_keys=False)
  File "/usr/lib/python2.7/dist-packages/yaml/__init__.py", line 202, in dump
    return dump_all([data], stream, Dumper=Dumper, **kwds)
TypeError: dump_all() got an unexpected keyword argument 'sort_keys'

cmake-format 0.6.10, default config

cheshirekow commented 4 years ago

I think this is what happens with an older pyyaml. Can you try upgrading your pyyaml and see if that fixes the issue?

dandrestor commented 4 years ago

Upgrading to pyyaml 5.3.1 fixes the issue

cheshirekow commented 4 years ago

Ok cool. Did you follow the installation instructions to install with the optional YAML dependency? I'd like to know if pyyaml didn't update on it's own (it should have).

If you wish to use a configuration file in YAML format you’ll want to install with the optional YAML feature, e.g.:

pip install cmake_format[YAML]

dandrestor commented 4 years ago

I installed with pip install cmake-format. So I didn't install the optional feature. I never got as far as reading the detailed docs you linked, I just briefly looked at the README on the GitHub repo landing page.

(Note I used a minus, not an underscore - is that a typo in the docs?)

cheshirekow commented 4 years ago

is that a typo in the docs?

The minus/underscore are treated the same by pypi, so it's not exactly a typo... though I think they prefer us to use minus these days so it's probably worth making it consistent.

Anyway, sounds like you've got this worked out so I'll close the issue. Feel free to add another comment if you have more to discuss.