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

Errors parsing yaml lists of dictionaries #81

Open
sg3-141-592 opened this issue Aug 8, 2023 · 1 comment
Open

Errors parsing yaml lists of dictionaries #81

sg3-141-592 opened this issue Aug 8, 2023 · 1 comment

Comments

@sg3-141-592
Copy link

sg3-141-592 commented Aug 8, 2023

Tested using niet ==3.2.0 and python 3.11.1

When trying to parse dictionaries that are in a list we get an error

niet -f eval . test.yaml
hello:
  world:
    - abc : 123
    - def : 456
Traceback (most recent call last):
  File "/workspace/.pyenv_mirror/user/3.11.1/bin/niet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/workspace/.pyenv_mirror/user/current/lib/python3.11/site-packages/niet/__init__.py", line 287, in main
    print_result(result, out_format, in_format, search, out_file)
  File "/workspace/.pyenv_mirror/user/current/lib/python3.11/site-packages/niet/__init__.py", line 226, in print_result
    output = VALID_PRINTERS[out_format]["cmd"](res, search)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/.pyenv_mirror/user/current/lib/python3.11/site-packages/niet/output.py", line 80, in print_eval
    results = _findevalitem(res, search)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/.pyenv_mirror/user/current/lib/python3.11/site-packages/niet/output.py", line 64, in _findevalitem
    item = _findevalitem(v, k)
           ^^^^^^^^^^^^^^^^^^^
  File "/workspace/.pyenv_mirror/user/current/lib/python3.11/site-packages/niet/output.py", line 69, in _findevalitem
    el.append("{k}=( {value} )".format(k=k, value=" ".join(v)))
                                                  ^^^^^^^^^^^
@sg3-141-592 sg3-141-592 changed the title Errors parsing lists of dictionaries Errors parsing yaml lists of dictionaries Aug 8, 2023
@4383
Copy link
Member

4383 commented Jan 11, 2024

Hello,

Thanks for reporting this issue and sorry for the late reply.

I think the error is related to the presence of the dash in lines with abc and def.

If I remove these dashes, then, the error disappear:

$ tox -r -e venv -- niet -f eval . /tmp/test.yaml
...
venv: commands[0]> niet -f eval . /tmp/test.yaml
hello__world__abc="123";hello__world__def="456"
.pkg: _exit> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True hatchling.build
  venv: OK (8.86=setup[8.76]+cmd[0.10] seconds)
  congratulations :) (8.99 seconds)

Is these dashes are mandatory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants