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

Parsing of dict is failing in v3.18.0 #87

Closed
Andry-Bal opened this issue Aug 23, 2021 · 7 comments
Closed

Parsing of dict is failing in v3.18.0 #87

Andry-Bal opened this issue Aug 23, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@Andry-Bal
Copy link

Andry-Bal commented Aug 23, 2021

Code to reproduce the issue:

from typing import Dict
from jsonargparse import ArgumentParser, ActionConfigFile


class Foo:
    def __init__(self, d: Dict[int, str]):
        pass


cfg = """
d:
    1: val1
    2: val2
"""


def main():
    parser = ArgumentParser()
    parser.add_class_arguments(Foo)
    parser.add_argument('--config', action=ActionConfigFile)
    parser.parse_args(['--config', cfg])


if __name__ == '__main__':
    main()

Current behavior:

Exits with:
error: keywords must be strings

@mauvilsa
Copy link
Member

From the title do you mean that this worked on previous versions but now is failing in v3.18.0? If it did work before could you please say in which jsonargparse and python version.

@Andry-Bal
Copy link
Author

Andry-Bal commented Aug 24, 2021

Yes, it works with Python 3.9.5 and jsonargparse 3.17.0.

@mauvilsa mauvilsa added the bug Something isn't working label Aug 26, 2021
@Andry-Bal
Copy link
Author

Same thing with Python 3.9.6 and jsonargparse 3.19.0.

@mauvilsa
Copy link
Member

Yes, I know. I modified the code above so that the same problem is reproduced in earlier versions of python.

@mauvilsa
Copy link
Member

mauvilsa commented Sep 3, 2021

Currently I am refactoring a core part of jsonargparse which has been the main cause of many issues including this one. Thus it will take a bit to get this fixed.

@mauvilsa
Copy link
Member

This should already be working correctly in the refactoring branch I am currently working on, see https://github.com/omni-us/jsonargparse/tree/refactor-namespace. You can already try it out. Note that this will be included in a major release of jsonargparse (v4.0.0) which still will take some more time.

@mauvilsa
Copy link
Member

mauvilsa commented Nov 1, 2021

The fix is now in the master branch. As said this will be part of the next major release.

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