From 46c226d7742d1b17ff82ccec653d062a46da408d Mon Sep 17 00:00:00 2001 From: "M. Kocher" Date: Wed, 18 Sep 2024 17:20:40 -0700 Subject: [PATCH] Remove cli key from json_schema_extras to avoid having it displayed --- pydantic_cli/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pydantic_cli/__init__.py b/pydantic_cli/__init__.py index 1309672..07e3ac4 100644 --- a/pydantic_cli/__init__.py +++ b/pydantic_cli/__init__.py @@ -130,13 +130,16 @@ def _add_pydantic_field_to_parser( """ default_long_arg = "".join([long_prefix, field_id]) - description = field_info.description # there's mypy type issues here cli_custom_: Tuple1or2Type = ( (default_long_arg,) if field_info.json_schema_extra is None # type: ignore else field_info.json_schema_extra.get("cli", (default_long_arg,)) # type: ignore ) + # Delete cli so the metadata isn't in FieldInfo and won't be displayed + if field_info.json_schema_extra: + _ = field_info.json_schema_extra.pop("cli", None) + cli_short_long: Tuple1or2Type = __process_tuple(cli_custom_, default_long_arg) is_required = field_info.is_required()