I am getting an when parsing a list of dataclass objects, where the dataclass has an optional member which is another dataclass.
To reproduce
In script.py
from dataclasses import dataclass
from typing import Optional
from jsonargparse import CLI
@dataclass
class A:
x: int
@dataclass
class B:
a: Optional[A] = None
def f(b: list[B]):
print(b)
CLI(f, as_positional=False)
In config.yaml
b:
- a:
x: 1
In terminal
script.py --config config.yaml
Expected behavior
Expected console output
[B(a=A(x=1))]
Actual console output
usage: script.py [-h] [--config CONFIG] [--print_config[=flags]] --b B
error: Validation failed: No action for key "a.x" to set its default.
Environment
jsonargparse version: 4.29.0
Python version: 3.11.4
How jsonargparse was installed: pip install jsonargparse[signatures]
🐛 Bug report
I am getting an when parsing a list of
dataclass
objects, where thedataclass
has an optional member which is anotherdataclass
.To reproduce
In
script.py
In
config.yaml
In terminal
Expected behavior
Expected console output
Actual console output
Environment
pip install jsonargparse[signatures]