allow other non pydantic arguments in typer functions

This commit is contained in:
Waylon Walker 2023-04-27 21:47:58 -05:00
parent ff522f24a6
commit cb95da6407
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4

View file

@ -52,7 +52,11 @@ def make_annotation(name, field, names, typer=False):
else str(field.annotation)
)
if field.default is None and not getattr(field, "required", False):
if "=" not in repr(field) and not hasattr(field, "required"):
default = "=None"
elif not hasattr(field, "required"):
default = f'="{field.default}"'
elif field.default is None and not getattr(field, "required", False):
if typer:
default = f' = typer.Option(None, help="{field.field_info.description or ""}", rich_help_panel="{panel_name}")'
else: