Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings source for AWS Secrets Manager #176

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ _build/
/.ghtopdep_cache/
/worktrees/
/.ruff_cache/
.pdm-python
31 changes: 31 additions & 0 deletions pydantic_settings/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,34 @@
return lenient_issubclass(annotation, (BaseModel, Mapping, Sequence, tuple, set, frozenset, deque)) or is_dataclass(
annotation
)

class AWSSecretManagerSettingsSource(PydanticBaseSettingsSource):
"""
Supports the AWS Secret Manager

Args:
PydanticBaseSettingsSource (_type_): _description_
"""
def __repr__(self) -> str:
return (

Check warning on line 659 in pydantic_settings/sources.py

View check run for this annotation

Codecov / codecov/patch

pydantic_settings/sources.py#L659

Added line #L659 was not covered by tests
f'AWSSecretManagerSettingsSource'
)

def get_field_value(self, field: FieldInfo, field_name: str) -> tuple[Any, str, bool]:
"""
Gets the value, the key for model creation, and a flag to determine whether value is complex.

This is an abstract method that should be overridden in every settings source classes.

Args:
field: The field.
field_name: The field name.

Returns:
A tuple contains the key, value and a flag to determine whether value is complex.
"""
pass

Check warning on line 676 in pydantic_settings/sources.py

View check run for this annotation

Codecov / codecov/patch

pydantic_settings/sources.py#L676

Added line #L676 was not covered by tests

@abstractmethod
def __call__(self) -> dict[str, Any]:
pass

Check warning on line 680 in pydantic_settings/sources.py

View check run for this annotation

Codecov / codecov/patch

pydantic_settings/sources.py#L680

Added line #L680 was not covered by tests
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ build-backend = 'hatchling.build'
[tool.hatch.version]
path = 'pydantic_settings/version.py'






[tool.pdm.dev-dependencies]
test = [
"pytest>=7.4.2",
"pytest-examples>=0.0.10",
"pytest-mock>=3.11.1",
]
[project]
name = 'pydantic-settings'
description = 'Settings management using Pydantic'
Expand Down
Loading