-
-
Notifications
You must be signed in to change notification settings - Fork 97
CLI submodel suppress. #587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks @kschwab. I resolved the conflicts |
Hey, thanks for working on this already! I think the fix would be to also set
e.g.: is_model_suppressed = self._is_field_suppressed(field_info) or is_model_suppressed
model_group_kwargs['description'] = CLI_SUPPRESS if is_model_suppressed else field_info.description like doing it a bit later in this function when adding the json argument:
I am not sure if this is documented behavior by argparse, but i looked at the source and this is what it does. ¹ ¹ See here: |
The test can be made to fail with this test changes: diff --git a/tests/test_source_cli.py b/tests/test_source_cli.py
index 6c523ff..6eb7421 100644
--- a/tests/test_source_cli.py
+++ b/tests/test_source_cli.py
@@ -2153,6 +2153,8 @@ def test_cli_app_exceptions():
def test_cli_suppress(capsys, monkeypatch):
class DeepHiddenSubModel(BaseModel):
+ """DeepHiddenSubModel class docstring"""
+
deep_hidden_a: int
deep_hidden_b: int
@@ -2166,10 +2168,10 @@ def test_cli_suppress(capsys, monkeypatch):
visible_b: int
deep_hidden_obj: CliSuppress[DeepHiddenSubModel]
- class Settings(BaseSettings, cli_parse_args=True):
+ class Settings(BaseSettings, cli_parse_args=True, cli_use_class_docs_for_groups=True):
field_a: CliSuppress[int] = 0
field_b: str = Field(default=1, description=CLI_SUPPRESS)
- hidden_obj: CliSuppress[HiddenSubModel]
+ hidden_obj: CliSuppress[HiddenSubModel] = Field(description='hidden_obj description')
visible_obj: SubModel |
Fixes #586