Skip to content

Commit c56f430

Browse files
committed
fix: 🐛 fixed load nested config from env
1 parent ffb3ac6 commit c56f430

File tree

1 file changed

+4
-1
lines changed
  • pydantic_settings/sources/providers

1 file changed

+4
-1
lines changed

pydantic_settings/sources/providers/env.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ class Cfg(BaseSettings):
186186
type_has_key = self.next_field(type_, key, case_sensitive)
187187
if type_has_key:
188188
return type_has_key
189-
if is_model_class(annotation) or is_pydantic_dataclass(annotation): # type: ignore[arg-type]
189+
if _lenient_issubclass(get_origin(annotation), dict):
190+
# get value type if it's a dict
191+
return get_args(annotation)[-1]
192+
elif is_model_class(annotation) or is_pydantic_dataclass(annotation): # type: ignore[arg-type]
190193
fields = _get_model_fields(annotation)
191194
# `case_sensitive is None` is here to be compatible with the old behavior.
192195
# Has to be removed in V3.

0 commit comments

Comments
 (0)