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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot manipulate dict #289
Comments
Thank you very much for reporting! Indeed there is a bug, though there are inconsistencies in the description. Thus, some clarifications are needed. Dataclasses don't behave like subclasses (see #287), so the config A slightly simpler reproduction which avoids using features unrelated to the bug is: from jsonargparse import ArgumentParser
from typing import Any, Dict, Optional
from dataclasses import dataclass
@dataclass
class ModelConfig:
data: Optional[Dict[str, Any]] = None
parser = ArgumentParser()
parser.add_argument("--model", type=Optional[ModelConfig], default=ModelConfig(data={"A": 1, "B": 2}))
parser.parse_args(["--model.data.A=4"])
print(cfg.model.data) I have created pull request #290 with a fix. @rob-hen please have a look. |
馃悰 Bug report
To reproduce
python file
mwe.py
:yaml file
mwe.yaml
:python mwe.py --config mwe.yaml
outputs:{'A': 1, 'B': 2}
However,
python mwe.py --config mwe.yaml --model.init_args.data.A=4
produces the error message:Expected behavior
The dictionary should have been modified to
{'A': 4, 'B': 2}
Environment
pip install jsonargparse
.The text was updated successfully, but these errors were encountered: