Closed dreamilization closed 11 months ago
Thanks for flagging this!
On our end I'm happy to either improve the error message or silently convert the type when the default doesn't match. The latter feels weird, so I'd need to think about it.
But ultimately this looks like an error that should be fixed in the transformers
code, right? It seems incorrect to create a field that's annotated as dict
but defaults to None
.
I agree! The code snippet from transformers
was recently implemented.
I think some error message can be helpful to figure out what went wrong without letting the user to dive into the source code too much as sometimes these can get pretty nested.
Regarding converting the type, maybe adding one additional check to determine whether the default is None or not can be helpful? I.e. treat that variable as Optional[TYPE] type if the default is None. Again, this will be your call.
Ok! The newest release should expand the type to Optional[T]
after raising a warning.
Version: 0.5.14
tyro.cli()
fails for the following part of the code - SourceException traceback:
I suspect that this might be due to the type hint is not Optional but dict. Since the default does set it as None, maybe tyro should handle this case as well?