From 2ca135206e4285d54c283ca4cc66a5c5dbb98cd3 Mon Sep 17 00:00:00 2001 From: Kyle Schwab Date: Fri, 12 Jul 2024 15:15:27 -0600 Subject: [PATCH] Update error message string. --- pydantic_settings/sources.py | 2 +- tests/test_settings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pydantic_settings/sources.py b/pydantic_settings/sources.py index 53647c7..1292d31 100644 --- a/pydantic_settings/sources.py +++ b/pydantic_settings/sources.py @@ -140,7 +140,7 @@ def get_subcommand(model: BaseModel, is_required: bool = False, is_exit_on_error return getattr(model, field_name) subcommands.append(field_name) if is_required: - error_message = f'CLI subcommand is required {{{", ".join(subcommands)}}}' + error_message = f'Error: CLI subcommand is required {{{", ".join(subcommands)}}}' raise SystemExit(error_message) if is_exit_on_error else SettingsError(error_message) return None diff --git a/tests/test_settings.py b/tests/test_settings.py index 52c5653..10c9f1e 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -2791,9 +2791,9 @@ class Git(BaseSettings): 'plugins': None, } assert get_subcommand(git) is None - with pytest.raises(SystemExit, match='CLI subcommand is required {clone, init, plugins}'): + with pytest.raises(SystemExit, match='Error: CLI subcommand is required {clone, init, plugins}'): get_subcommand(git, is_required=True) - with pytest.raises(SettingsError, match='CLI subcommand is required {clone, init, plugins}'): + with pytest.raises(SettingsError, match='Error: CLI subcommand is required {clone, init, plugins}'): get_subcommand(git, is_required=True, is_exit_on_error=False) git = Git(_cli_parse_args=['init', '--quiet', 'true', 'dir/path'])