Skip to content

Commit

Permalink
Fix potential problem
Browse files Browse the repository at this point in the history
  • Loading branch information
makukha committed Sep 3, 2024
1 parent 5e85247 commit 170c68d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pydantic_settings/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,7 @@ def __call__(self) -> dict[str, Any]:
return secrets

secrets_dirs = [self.secrets_dir] if isinstance(self.secrets_dir, (str, os.PathLike)) else self.secrets_dir
# directories reversed to match the last-wins behaviour of `env_file`
self.secrets_paths = list(reversed([Path(p).expanduser() for p in secrets_dirs]))
self.secrets_paths = [Path(p).expanduser() for p in secrets_dirs]

for path in self.secrets_paths:
if not path.exists():
Expand Down Expand Up @@ -643,7 +642,8 @@ def get_field_value(self, field: FieldInfo, field_name: str) -> tuple[Any, str,
"""

for field_key, env_name, value_is_complex in self._extract_field_info(field, field_name):
for secrets_path in self.secrets_paths:
# pathss reversed to match the last-wins behaviour of `env_file`
for secrets_path in reversed(self.secrets_paths):
path = self.find_case_path(secrets_path, env_name, self.case_sensitive)
if not path:
# path does not exist, we currently don't return a warning for this
Expand Down

0 comments on commit 170c68d

Please sign in to comment.