Skip to content

Commit

Permalink
CLI ignore prefix if validation_alias is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Schwab committed Aug 30, 2024
1 parent 47924f5 commit 95ef5df
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pydantic_settings/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,13 @@ def _add_parser_args(
)
elif is_alias_path_only:
continue
elif group is not None:

if arg_prefix and field_info.validation_alias is not None:
# Strip prefix if validation alias is set and value is not complex.
# See https://github.com/pydantic/pydantic-settings/pull/25
kwargs['dest'] = kwargs['dest'][self.env_prefix_len:]

if group is not None:
if isinstance(group, dict):
group = self._add_argument_group(parser, **group)
added_args += list(arg_names)
Expand Down

0 comments on commit 95ef5df

Please sign in to comment.