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
pyhocon can't parse nested YAML maps #50
Comments
@deleted thanks for the feedback. We will take a look at this. |
@dwsmith1983 I'm not sure I'm quite understanding your comment above:
Can you clarify? I will attempt to reframe the issue: The test case here is, in YAML terms, a top-level In [17]: conf = """
...: b:
...: c: test
...: """
In [18]: dataconf.dict(yaml.load(conf, Loader=yaml.SafeLoader), A)
Out[18]: A(b=B(c='test')) But if we call dataconf.loads(conf, A) we get that |
@zifeo I was saying that it is read as nested dictionaries not dataclasses in that yaml format. |
@deleted @dwsmith1983 Thanks for the report. I have been playing a bit more with the PyHocon library to which we are delegating the parsing. It turns out that yaml support within Dataconf is a bit a misnomer (load KO, dump OK). Both yaml and hocon can be seen a superset of json (hocon with some java .properties features), however the relation between them is not well defined (e.g. not mixeable). Thus PyHocon does not currently support yaml: >>> from pyhocon import ConfigFactory
>>> ConfigFactory.parse_string("""
... b:
... {c: test}
... """)
ConfigTree([('b', ConfigTree([('c', 'test')]))])
>>> ConfigFactory.parse_string("""
... b:
... c: test
... """)
ConfigTree([('b', 'c: test')]) I see two options:
@deleted I am curious about your use case. Can you tell me a bit more? Would hocon be an option? |
@zifeo I think two is better. YAML to HOCON or JSON instead isn't a big change on the users end. |
@zifeo HOCON seems pretty nice, I'd prefer YAML because it a more standard config file format in the community at large. I'd be concerned that some of my users might balk at having to learn a new config language. Another option I'll throw out there for you guys is that you could add a |
@deleted While I am not a huge fan of adding |
@deleted released in 2.1.0, cheers |
Woot! Thanks @zifeo! |
I discovered this while trying to use dataconf to parse a YAML config file with one level of nesting.
For example, adding the following to
test_parse.py
:This test should pass, but results in the following test failure:
Changing the input to:
causes the test to pass, but I suspect this is because it is coincedentally also valid HOCON.
The text was updated successfully, but these errors were encountered: