-
-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
🐛 Bug report
When define a parameter of a class to be callable type, it is unable to specify a path for this parameter.
To reproduce
from collections.abc import Callable
from jsonargparse import ArgumentParser
class B:
def __init__(self, x: int):
self.x = x
class A:
def __init__(self, b: Callable[[int], B]):
self.b = b(id(self))
def main():
parser = ArgumentParser()
parser.add_class_arguments(A, 'a', sub_configs=True)
'''
content of b.yaml:
class_path: B
'''
args = parser.parse_args(['--a.b', 'b.yaml'])
if __name__ == '__main__':
main()
Expected behavior
Actual output
usage: test.py [-h] [--a CONFIG] --a.b B
error: Parser key "a.b":
Type collections.abc.Callable[[int], __main__.B] expects a function or a callable class: No module named 'b'. Got value: b.yaml
Environment
- jsonargparse version: 4.27.0
- Python version: 3.11.6
- How jsonargparse was installed:
jsonargparse[signatures, omegaconf]
- OS: Linux
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working