-
-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
enhancementNew feature or requestNew feature or request
Description
🐛 Bug report
When instantiating objects from a custom class where a default is specified in the signature, jsonargparse infers the defaults from the the wrong class:
To reproduce
from jsonargparse import CLI
class Super:
pass
class Default(Super):
def __init__(self, foo: str = "foo", bar: str = "bar"):
self.foo = foo
self.bar = bar
class Other(Super):
def __init__(self, foo: str = "foo", bar: str = "baaaaar"):
self.foo = foo
self.bar = bar
def main(data: Super = Default()):
print(data.foo)
print(data.bar)
if __name__ == "__main__":
CLI(main)python repro.py --data Other --data.foo test
Output:
test
bar
Expected behavior
I expect the output to be
test
baaaaar
because I selected --data Other, so it should use the defaults from the Other class.
Environment
- jsonargparse version (e.g., 4.8.0): 4.27.5
- Python version (e.g., 3.9): 3.10
- How jsonargparse was installed (e.g.
pip install jsonargparse[all]):pip install -U jsonargparse[signatures] - OS (e.g., Linux): MacOS and Linux
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request