Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pydantic_settings/sources/providers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ def _resolve_parsed_args(self, parsed_args: dict[str, list[str] | str]) -> list[
elif field_name.endswith(':subcommand') and val is not None:
selected_subcommands.append(self._parser_map[field_name][val].dest)
elif self.cli_kebab_case == 'all':
if isinstance(val, bool):
continue
snake_val = val.replace('-', '_')
cli_arg = self._parser_map.get(field_name, {}).get(None)
if (
Expand Down
16 changes: 16 additions & 0 deletions tests/test_source_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2606,6 +2606,22 @@ class SettingsAll(BaseSettings):
CliApp.run(SettingsAll, cli_args=['--example', 'example_a', '--mybool=true'])


def test_cli_kebab_case_all_with_implicit_flag():
class Settings(BaseSettings):
model_config = SettingsConfigDict(cli_kebab_case='all')
test_bool_flag: CliImplicitFlag[bool]

assert CliApp.run(
Settings,
cli_args=['--test-bool-flag'],
).model_dump() == {'test_bool_flag': True}

assert CliApp.run(
Settings,
cli_args=['--no-test-bool-flag'],
).model_dump() == {'test_bool_flag': False}


def test_cli_with_unbalanced_brackets_in_json_string():
class StrToStrDictOptions(BaseSettings):
nested: dict[str, str]
Expand Down