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

No error message when using ArgumentParser.instantiate_classes() #81

Closed
yunxie12 opened this issue Aug 13, 2021 · 3 comments
Closed

No error message when using ArgumentParser.instantiate_classes() #81

yunxie12 opened this issue Aug 13, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@yunxie12
Copy link

Hello, I found some odd codes at

except KeyError:
.
I am confused why KeyError should be ignored. When instantiating a class, KeyError is common, for example, try to get a value from a dict using a nonexistent key. It takes me lots of time to debug my code with KeyError.
Anyway, jsonargparse is a great package and help me a lot.
I wish we can discuss my confusion.

@mauvilsa
Copy link
Member

I think you are right, that is a mistake. The try should only wrap the _get_key_value line and only if no exception the rest would be executed. Would you like to create a pull request with the fix?

@mauvilsa mauvilsa added the bug Something isn't working label Aug 13, 2021
mauvilsa added a commit that referenced this issue Aug 16, 2021
…gument.

- Don't ignore ``KeyError`` in call to instantiate_classes #81.
- Fixed optional subcommands fail with a KeyError #68.
@mauvilsa
Copy link
Member

Since there was no response I went ahead and fixed it. Currently in master and will be part of the next release. @yunxie12 please try again with jsonargparse from master your code in which the instantiation gave KeyError to verify that the fix worked.

@yunxie12
Copy link
Author

The fix works. Thanks you!

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