You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueError: Does not validate against any of the Union subtypes
Subtypes: (<class '__main__.A'>, <class '__main__.B'>)
Errors:
- 'LazyInstance_B' object has no attribute 'b'
- B.__init__() got an unexpected keyword argument 'a'
Given value type: <class 'jsonargparse._namespace.Namespace'>
Given value: Namespace(a=1)
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
The text was updated successfully, but these errors were encountered:
I think I'm encountering this or a similar bug when I try to parse a union of attrs classes. The attached testcase
fails when I try to use the second type in a union, with the following output:
E argparse.ArgumentError: Validation failed: Parser key "data":
E Does not validate against any of the Union subtypes
E Subtypes: (<class 'jsonargparse_tests.test_dataclass_like.AttrsData'>, <class 'jsonargparse_tests.test_dataclass_like.AttrsData2'>)
E Errors:
E - No action for key "p4" to set its default.
E - No action for key "p1" to set its default.
E Given value type: <class 'jsonargparse._namespace.Namespace'>
E Given value: Namespace(p1=None, p2='-', p4=1)
jsonargparse/_core.py:1010: ArgumentError
@mnidza just now I reran the reproduction script and it works as expected, giving [A(a=1), B(b=2)]. I am not sure in which change this was fixed. @nkrishnaswami also the TestAttrs::test_union test passes now. Please check and if you like, create a pull request to add your test case.
🐛 Bug report
I am getting an error when parsing a list of objects whose type is the union of two different
dataclass
es.To reproduce
In
script.py
In
config.yaml
In terminal
Expected behavior
Expected console output
Actual console output
Environment
pip install jsonargparse[signatures]
The text was updated successfully, but these errors were encountered: