Skip to content
Closed
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
16 changes: 16 additions & 0 deletions pydantic_settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,22 @@ def _settings_build_values(
# to an informative error and much better than a confusing error
return {}



@classmethod
def from_dotenv(
cls,
env_file: DotenvType,
case_sensitive: bool | None = None,
) -> "BaseSettings":
case_sensitive = case_sensitive if case_sensitive is not None else cls.model_config.get('case_sensitive')
env_file = env_file
dotenv_settings = DotEnvSettingsSource(
cls,
env_file=env_file,
)
return cls.model_validate(dotenv_settings())

model_config: ClassVar[SettingsConfigDict] = SettingsConfigDict(
extra='forbid',
arbitrary_types_allowed=True,
Expand Down
Loading