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

Default values can't look like {{something}} #189

Closed
dconathan opened this issue Nov 7, 2022 · 2 comments
Closed

Default values can't look like {{something}} #189

dconathan opened this issue Nov 7, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@dconathan
Copy link

🐛 Bug report

Default values can't look like {{something}}

To reproduce

import jsonargparse

# Here define one or more functions or classes
def func1(param1: str="{{something}}"):
    ...

# Run the CLI providing the components
jsonargparse.CLI([func1], error_handler=None)

Invoking this fails with a long traceback that looks like something related to encoding the default value as yaml?

    raise ConstructorError("while constructing a mapping", node.start_mark,
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 1, column 1
found unhashable key
  in "<unicode string>", line 1, column 2

My guess is because if this is a value in yaml it looks like you're trying to build a dict with a dict as a key. Is there a workaround for this? My use case is I want to pass in jinja template-like things.

Expected behavior

The CLI would run without error.

Environment

  • jsonargparse version (e.g., 4.8.0): 4.16.0
  • Python version (e.g., 3.9): 3.10
  • How jsonargparse was installed (e.g. pip install jsonargparse[all]): pip install jsonargparse
  • OS (e.g., Linux): MacOS
@dconathan dconathan added the bug Something isn't working label Nov 7, 2022
@mauvilsa
Copy link
Member

mauvilsa commented Nov 8, 2022

Thank you for reporting! I just pushed a fix for this in commit 72672b4.

@mauvilsa mauvilsa closed this as completed Nov 8, 2022
@dconathan
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants