task: metadata: install: pip install -e .[dev]
patch: diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 232e5aa..16db672 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -32,6 +32,8 @@ Fixed
   <https://github.com/omni-us/jsonargparse/issues/517>`__).
 - Callable that returns class not using required parameter default from lambda
   (`#523 <https://github.com/omni-us/jsonargparse/pull/523>`__).
+- Failing to parse list of dataclasses with nested optional dataclass (`#527
+  <https://github.com/omni-us/jsonargparse/pull/527>`__).
 
 
 v4.29.0 (2024-05-24)
diff --git a/jsonargparse/_signatures.py b/jsonargparse/_signatures.py
index 8a40804..133f9c0 100644
--- a/jsonargparse/_signatures.py
+++ b/jsonargparse/_signatures.py
@@ -103,7 +103,7 @@ class SignatureArguments(LoggerProperty):
             prefix = nested_key + "." if nested_key else ""
             defaults = default.lazy_get_init_args()
             if defaults:
-                defaults = {prefix + k: v for k, v in defaults.items() if k not in skip}
+                defaults = {prefix + k: v for k, v in defaults.__dict__.items() if k not in skip}
                 self.set_defaults(**defaults)  # type: ignore[attr-defined]
 
         return added_args

problem_statement: Cannot parse a list of dataclasses with optional dataclass member
<!-- If you like this project, please ⭐ star it https://github.com/omni-us/jsonargparse/ -->

## 🐛 Bug report

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`
```python
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`
```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]`
- OS: Windows 11 Enterprise, 10.0.22631

repo: omni-us/jsonargparse
test_cmd: pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
test_patch: diff --git a/jsonargparse_tests/test_dataclass_like.py b/jsonargparse_tests/test_dataclass_like.py
index cbaa97d..995f740 100644
--- a/jsonargparse_tests/test_dataclass_like.py
+++ b/jsonargparse_tests/test_dataclass_like.py
@@ -186,6 +186,22 @@ def test_add_class_optional_without_default(parser):
     assert parser.parse_args(["--param=null"]) == Namespace(param=None)
 
 
+@dataclasses.dataclass
+class ListOptionalA:
+    x: int
+
+
+@dataclasses.dataclass
+class ListOptionalB:
+    a: Optional[ListOptionalA] = None
+
+
+def test_list_nested_optional_dataclass(parser):
+    parser.add_argument("--b", type=List[ListOptionalB])
+    cfg = parser.parse_args(['--b=[{"a":{"x":1}}]'])
+    assert cfg.b == [Namespace(a=Namespace(x=1))]
+
+
 def test_add_argument_dataclass_type(parser):
     parser.add_argument("--b", type=DataClassB, default=DataClassB(b1=7.0))
     cfg = parser.get_defaults()