-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip(manifests): Added
manifests.py
and loader kwargs.
This should work for #22.
- Loading branch information
1 parent
6a78363
commit 0c425bd
Showing
4 changed files
with
121 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""For non settings/configuration files. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any, Self | ||
|
||
from pydantic import BaseModel | ||
|
||
from yaml_settings_pydantic import loader | ||
|
||
|
||
class BaseYaml(BaseModel): | ||
"""Pydantic model loadable from yaml. See :meth:`load`.""" | ||
|
||
@classmethod | ||
def load( | ||
cls, | ||
*, | ||
overwrite: dict[str, Any] | None = None, | ||
exclude: dict[str, Any] | None = None, | ||
**yaml_settings: loader.YamlSettingsConfigDict, | ||
) -> Self: | ||
|
||
if (yaml_files := yaml_settings.get("yaml_files")) is None: | ||
raise ValueError() | ||
|
||
yaml_files_config = loader.validate_yaml_settings_config_files(yaml_files) | ||
yaml_files_data = loader.load_yaml_data(yaml_files_config) | ||
data = loader.validate_yaml_data( | ||
yaml_files_data, | ||
overwrite=overwrite, | ||
exclude=exclude, | ||
) | ||
|
||
return cls.model_validate(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters