We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
KeyError
from jsonargparse import ArgumentParser parser = ArgumentParser() subcommands = parser.add_subcommands(required=False) subparser = ArgumentParser() subcommands.add_subcommand('foo', subparser) parser.parse_args()
When called with no subcommand, prints:
Error: None
After some debugging, I found two issues:
(1):
jsonargparse/jsonargparse/actions.py
Line 767 in e7ab0f3
should be replaced with
subparser = action._name_parser_map.get(subcommand) if subparser is None: return
(2):
KeyErrors should not be catched here:
jsonargparse/jsonargparse/core.py
Lines 396 to 397 in e7ab0f3
which hides the original exception when it seems to be an actual bug:
Traceback (most recent call last): File "/Users/carlosmocholi/Library/Application Support/JetBrains/PyCharmCE2020.3/scratches/scratch_12.py", line 8, in <module> parser.parse_args() File "/Users/carlosmocholi/.pyenv/versions/3.9.1/envs/lightning-3.9/lib/python3.9/site-packages/jsonargparse/core.py", line 385, in parse_args parsed_cfg = self._parse_common( File "/Users/carlosmocholi/.pyenv/versions/3.9.1/envs/lightning-3.9/lib/python3.9/site-packages/jsonargparse/core.py", line 308, in _parse_common _ActionSubCommands.handle_subcommands(self, cfg, env=env, defaults=defaults, fail_no_subcommand=fail_no_subcommand) File "/Users/carlosmocholi/.pyenv/versions/3.9.1/envs/lightning-3.9/lib/python3.9/site-packages/jsonargparse/actions.py", line 767, in handle_subcommands subparser = action._name_parser_map[subcommand] KeyError: None
The text was updated successfully, but these errors were encountered:
- Don't discard init_args with non-changing --*.class_path ar…
init_args
--*.class_path
cdd0ea5
…gument. - Don't ignore ``KeyError`` in call to instantiate_classes #81. - Fixed optional subcommands fail with a KeyError #68.
The fix is now in master.
Sorry, something went wrong.
No branches or pull requests
When called with no subcommand, prints:
After some debugging, I found two issues:
(1):
jsonargparse/jsonargparse/actions.py
Line 767 in e7ab0f3
should be replaced with
(2):
KeyErrors should not be catched here:
jsonargparse/jsonargparse/core.py
Lines 396 to 397 in e7ab0f3
which hides the original exception when it seems to be an actual bug:
The text was updated successfully, but these errors were encountered: