10000 ValueError: not enough values to unpack (expected 2, got 1) · Issue #6 · Chris1221/yamldoc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ValueError: not enough values to unpack (expected 2, got 1) #6

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

Closed
kayx23 opened this issue May 15, 2023 · 4 comments · Fixed by #15
Closed

ValueError: not enough values to unpack (expected 2, got 1) #6

kayx23 opened this issue May 15, 2023 · 4 comments · Fixed by #15

Comments

@kayx23
Copy link
kayx23 commented May 15, 2023

What works

test:
  - a: 3
  - b: 6

What doesn't work

port:
  - 1094
  - 2832

Got the following error msg:

Traceback (most recent call last):
  File "/home/codespace/.local/bin/yamldoc", line 33, in <module>
    sys.exit(load_entry_point('yamldoc==0.1.6', 'console_scripts', 'yamldoc')())
  File "/home/codespace/.local/lib/python3.10/site-packages/yamldoc-0.1.6-py3.10.egg/yamldoc/cli.py", line 14, in cli
  File "/home/codespace/.local/lib/python3.10/site-packages/yamldoc-0.1.6-py3.10.egg/yamldoc/parser.py", line 405, in main
  File "/home/codespace/.local/lib/python3.10/site-packages/yamldoc-0.1.6-py3.10.egg/yamldoc/parser.py", line 72, in parse_yaml
ValueError: not enough values to unpack (expected 2, got 1)

However this is also a valid yaml config that should be supported.

@Chris1221
Copy link
Owner

Thank you for the report, I believe this may be related to another issue that I found. I will look into this and get back to you.

@Chris1221
Copy link
Owner

Hey @kayx23, thanks again for the report. Would you mind checking if the solution proposed in #11 works for your use-case? I've allowed for array-valued entries.

As a side note, when looking into this I realised that there are a few bits of YAML syntax that I'm not really supporting here, I'll be adding a page that describes the currently unsupported (but of course possible, please continue to request things that are important) pieces of syntax to make things more clear.

@Chris1221
Copy link
Owner

As a test case I've added test/yaml/lists.yaml and test/schema/lists.schema.

The example above now renders as the following:

port.yaml:

#' test metadata
port:
  #' this will not be included
  - 1094
  - 2832

yamldoc port.yaml

Key Value Information
port ['1094', '2832'] test metadata

If you add in a schema file with an array type, this is also now recognized:

port.schema:

$schema: "http://json-schema.org/draft-04/schema#"

type: object

properties:
    port:
        type: array

yamldoc port.yaml -s port.schema

Key Value Type Information
port ['1094', '2832'] array test metadata

@Chris1221
Copy link
Owner
Chris1221 commented Jun 10, 2023

Btw I coopted that PR to improve testing and fix another issue that I found while investigating this one.

The following will now correctly work:

array_1:
  - 1
  - 2
  - 3

array_2:
  - 4
  - 5
  - 6
Key Value Information
array_1 ['1', '2', '3']
array_2 ['4', '5', '6']

I was previously relying on using the meta-data to "reset" the element detector, but I've relaxed that constraint and now both cases should be covered (subsequent element has meta-data or it doesn't).

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

Successfully merging a pull request may close this issue.

2 participants
0