Skip to content

Commit 1eb82ed

Browse files
committed
simple if/else
1 parent 2d469a6 commit 1eb82ed

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pydantic_settings/sources/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,16 @@ def _read_files(self, files: PathType | None, deep_merge: bool = False) -> dict[
198198
if isinstance(files, (str, os.PathLike)):
199199
files = [files]
200200
vars: dict[str, Any] = {}
201-
update = deep_update if deep_merge else self._shallow_update
202201
for file in files:
203202
file_path = Path(file).expanduser()
204-
if file_path.is_file():
205-
vars = update(vars, self._read_file(file_path))
206-
return vars
203+
if not file_path.is_file():
204+
continue
207205

208-
def _shallow_update(self, vars: dict[str, Any], updating_vars: dict[str, Any]) -> dict[str, Any]:
209-
# this mimics the semantics of pydantic._internal._utils.deep_update
210-
vars = vars.copy()
211-
vars.update(updating_vars)
206+
updating_vars = self._read_file(file_path)
207+
if deep_merge:
208+
vars = deep_update(vars, updating_vars)
209+
else:
210+
vars.update(updating_vars)
212211
return vars
213212

214213
@abstractmethod

0 commit comments

Comments
 (0)