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

Fix handling of --dump-config when there is no existing config file and when the existing config file is empty #117

Conversation

mtkennerly
Copy link

I ran into this problem when trying out the tool on a brand new install:

$ cmake-format --dump-config yaml
Traceback (most recent call last):
  File "c:\python\3.7-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python\3.7-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python\3.7-32\Scripts\cmake-format.exe\__main__.py", line 9, in <module>
  File "c:\python\3.7-32\lib\site-packages\cmake_format\__main__.py", line 389, in main
    dump_config(args, config_dict, sys.stdout)
  File "c:\python\3.7-32\lib\site-packages\cmake_format\__main__.py", line 253, in dump_config
    cfg = configuration.Configuration(**config_dict)
TypeError: type object argument after ** must be a mapping, not NoneType

With the fix:

$ cmake-format --dump-config yaml
line_width: 80
tab_size: 2
max_subargs_per_line: 3
separate_ctrl_name_with_space: false
separate_fn_name_with_space: false
dangle_parens: false
[...]

@mtkennerly mtkennerly force-pushed the bugfix/dump-config-without-existing-file branch from 2eef331 to 7894a3e Compare June 29, 2019 01:08
@cheshirekow cheshirekow self-assigned this Jun 29, 2019
@cheshirekow cheshirekow added acknowledged I've seen the report. I may not have anything more to say just yet! bug labels Jun 29, 2019
@cheshirekow
Copy link
Owner

I've tried to reproduce this error in a number of environments and I'm unable to do so. I also can't see how config_dict can ever be None in this location. Are you able to reproduce this error reliably?

@cheshirekow
Copy link
Owner

cheshirekow commented Jul 22, 2019

Hm... ok so I am only able to reproduce the problem with an empty configuration file. It only appears to be a problem with yaml configurations. Presumably apparently yaml.load returns None instead of an empty dictionary if a yaml file is empty... which is annoying.

Can you confirm that this error is not present if there is no config file in play? You said you had a brand new install but it seems like you had created a config file.

@cheshirekow
Copy link
Owner

I'm unable to reproduce with missing config but I fixed the case where yaml.load returns None. If you can reproduce the no-config case please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged I've seen the report. I may not have anything more to say just yet! bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants