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
First, create a file named demo.py with the following content:
demo.py
from typing import Optional from jsonargparse import CLI class Foo: ... class Bar(Foo): def __init__(self, val: int) -> None: self.val = val def main(data: Optional[Foo] = None) -> None: print(data) if __name__ == "__main__": CLI(main)
Then, run the following command in your terminal:
python demo.py --data Bar --data.val 1
The output is:
usage: demo.py [-h] [--config CONFIG] [--print_config[=flags]] [--data.help CLASS_PATH_OR_NAME] [--data DATA] error: cannot unpack non-iterable ActionTypeHint object
Such behavior will also affect LitGPT. For example, the command
litgpt finetune tiiuae/falcon-7b \ --data JSON \ --data.json_path data/mydata.json \ --out_dir data/mydata-finetuned
will also result in the same error because JSON is a subclass of DataModule.
JSON
DataModule
On Python 3.12.6, the output is:
<__main__.Bar object at 0x*******>
pip install jsonargparse==4.32.1
The text was updated successfully, but these errors were encountered:
Fix issue omni-us#590
afd078b
argparse._parse_optional
Fix issue #590: Behavior change in argparse._parse_optional breaks …
a209e1e
…the parse of optional arguments (#591)
Fixed with #591
Sorry, something went wrong.
No branches or pull requests
🐛 Bug report
To reproduce
First, create a file named
demo.py
with the following content:Then, run the following command in your terminal:
The output is:
Such behavior will also affect LitGPT. For example, the command
will also result in the same error because
JSON
is a subclass ofDataModule
.Expected behavior
On Python 3.12.6, the output is:
Environment
pip install jsonargparse==4.32.1
The text was updated successfully, but these errors were encountered: