From cb95da64070ce2d4e874e23d02afd1ecba49041e Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Thu, 27 Apr 2023 21:47:58 -0500 Subject: [PATCH] allow other non pydantic arguments in typer functions --- pydantic_typer/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pydantic_typer/__init__.py b/pydantic_typer/__init__.py index 9261504..8e4f310 100644 --- a/pydantic_typer/__init__.py +++ b/pydantic_typer/__init__.py @@ -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: