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
It took me a while to find a way to reproduce this bug, and it doesn't quite happen here in the way it's happening in our larger codebase, however I'd like to give it a go:
🐛 Bug report
Specifying types which have forward references included can lead to errors when the forward-referenced type is not in scope.
In this case ForwardReferenced is in scope when defining Direct, so adding class arguments will work. However, in the case of IndirectForwardReferenced is not in scope when using NamedType leading to an error when adding class variables.
I expect both Direct and Indirect class arguments to be addable, instead adding Indirect will throw a ValueError: ValueError: With fail_untyped=True, all mandatory parameters must have a supported type. Parameter 'data_type' from '__main__.Indirect.__init__' does not specify a type.
resolving it is trivial, you can either import the forward-referenced type within the current scope or remove the forward reference from the type.
I've found a similar case when using parser.link_arguments but have not quite been able to reproduce it. In our case it was quite hard to figure out the cause of the bug. At the very least there should be some impovement to error reporting.
Environment
jsonargparse version: 4.37.0
Python version: 3.11
How jsonargparse was installed: UV
OS: Pop!_OS 22.04 LTS
The text was updated successfully, but these errors were encountered:
It took me a while to find a way to reproduce this bug, and it doesn't quite happen here in the way it's happening in our larger codebase, however I'd like to give it a go:
🐛 Bug report
Specifying types which have forward references included can lead to errors when the forward-referenced type is not in scope.
In this case
ForwardReferenced
is in scope when definingDirect
, so adding class arguments will work. However, in the case ofIndirect
ForwardReferenced
is not in scope when usingNamedType
leading to an error when adding class variables.To reproduce
types_file
minimal_reproduction.py
Expected behavior
I expect both
Direct
andIndirect
class arguments to be addable, instead addingIndirect
will throw a ValueError:ValueError: With fail_untyped=True, all mandatory parameters must have a supported type. Parameter 'data_type' from '__main__.Indirect.__init__' does not specify a type.
resolving it is trivial, you can either import the forward-referenced type within the current scope or remove the forward reference from the type.
I've found a similar case when using parser.link_arguments but have not quite been able to reproduce it. In our case it was quite hard to figure out the cause of the bug. At the very least there should be some impovement to error reporting.
Environment
The text was updated successfully, but these errors were encountered: