Skip to content

Commit d90575d

Browse files
committed
tests for AWS Secrets Manager
1 parent 74b09c0 commit d90575d

File tree

8 files changed

+217
-21
lines changed

8 files changed

+217
-21
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refresh-lockfiles:
1313
find requirements/ -name '*.txt' ! -name 'all.txt' -type f -delete
1414
pip-compile -q --no-emit-index-url --resolver backtracking -o requirements/linting.txt requirements/linting.in
1515
pip-compile -q --no-emit-index-url --resolver backtracking -o requirements/testing.txt requirements/testing.in
16-
pip-compile -q --no-emit-index-url --resolver backtracking --extra toml --extra yaml --extra azure-key-vault -o requirements/pyproject.txt pyproject.toml
16+
pip-compile -q --no-emit-index-url --resolver backtracking --extra toml --extra yaml --extra azure-key-vault --extra aws-secrets-manager -o requirements/pyproject.txt pyproject.toml
1717
pip install --dry-run -r requirements/all.txt
1818

1919
.PHONY: format

pydantic_settings/sources.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ class Cfg(BaseSettings):
889889
type_has_key = self.next_field(type_, key, case_sensitive)
890890
if type_has_key:
891891
return type_has_key
892-
elif is_model_class(annotation) or is_pydantic_dataclass(annotation):
892+
elif is_model_class(annotation) or is_pydantic_dataclass(annotation): # type: ignore
893893
fields = _get_model_fields(annotation)
894894
# `case_sensitive is None` is here to be compatible with the old behavior.
895895
# Has to be removed in V3.
@@ -1786,11 +1786,13 @@ def _add_parser_args(
17861786
if isinstance(group, dict):
17871787
group = self._add_group(parser, **group)
17881788
added_args += list(arg_names)
1789-
self._add_argument(group, *(f'{flag_prefix[:len(name)]}{name}' for name in arg_names), **kwargs)
1789+
self._add_argument(
1790+
group, *(f'{flag_prefix[: len(name)]}{name}' for name in arg_names), **kwargs
1791+
)
17901792
else:
17911793
added_args += list(arg_names)
17921794
self._add_argument(
1793-
parser, *(f'{flag_prefix[:len(name)]}{name}' for name in arg_names), **kwargs
1795+
parser, *(f'{flag_prefix[: len(name)]}{name}' for name in arg_names), **kwargs
17941796
)
17951797

17961798
self._add_parser_alias_paths(parser, alias_path_args, added_args, arg_prefix, subcommand_prefix, group)
@@ -2247,7 +2249,7 @@ def _load_env_vars(self) -> Mapping[str, Optional[str]]:
22472249
return AzureKeyVaultMapping(secret_client)
22482250

22492251
def __repr__(self) -> str:
2250-
return f'{self.__class__.__name__}(url={self._url!r}, ' f'env_nested_delimiter={self.env_nested_delimiter!r})'
2252+
return f'{self.__class__.__name__}(url={self._url!r}, env_nested_delimiter={self.env_nested_delimiter!r})'
22512253

22522254

22532255
class AWSSecretsManagerSettingsSource(EnvSettingsSource):

requirements/linting.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.9
2+
# This file is autogenerated by pip-compile with Python 3.10
33
# by the following command:
44
#
55
# pip-compile --no-emit-index-url --output-file=requirements/linting.txt requirements/linting.in
66
#
77
black==25.1.0
88
# via -r requirements/linting.in
9-
boto3-stubs[secretsmanager]==1.36.15
9+
boto3-stubs[secretsmanager]==1.36.17
1010
# via -r requirements/linting.in
11-
botocore-stubs==1.36.15
11+
botocore-stubs==1.36.17
1212
# via boto3-stubs
1313
cfgv==3.4.0
1414
# via pre-commit
@@ -18,7 +18,7 @@ distlib==0.3.9
1818
# via virtualenv
1919
filelock==3.17.0
2020
# via virtualenv
21-
identify==2.6.6
21+
identify==2.6.7
2222
# via pre-commit
2323
mypy==1.15.0
2424
# via -r requirements/linting.in
@@ -46,15 +46,15 @@ pyyaml==6.0.2
4646
# via
4747
# -r requirements/linting.in
4848
# pre-commit
49-
ruff==0.9.5
49+
ruff==0.9.6
5050
# via -r requirements/linting.in
5151
tokenize-rt==6.1.0
5252
# via pyupgrade
5353
tomli==2.2.1
5454
# via
5555
# black
5656
# mypy
57-
types-awscrt==0.23.9
57+
types-awscrt==0.23.10
5858
# via botocore-stubs
5959
types-pyyaml==6.0.12.20241230
6060
# via -r requirements/linting.in
@@ -66,5 +66,5 @@ typing-extensions==4.12.2
6666
# boto3-stubs
6767
# mypy
6868
# mypy-boto3-secretsmanager
69-
virtualenv==20.29.1
69+
virtualenv==20.29.2
7070
# via pre-commit

requirements/pyproject.txt

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.9
2+
# This file is autogenerated by pip-compile with Python 3.10
33
# by the following command:
44
#
5-
# pip-compile --extra=azure-key-vault --extra=toml --extra=yaml --no-emit-index-url --output-file=requirements/pyproject.txt pyproject.toml
5+
# pip-compile --extra=aws-secrets-manager --extra=azure-key-vault --extra=toml --extra=yaml --no-emit-index-url --output-file=requirements/pyproject.txt pyproject.toml
66
#
77
annotated-types==0.7.0
88
# via pydantic
@@ -14,6 +14,16 @@ azure-identity==1.19.0
1414
# via pydantic-settings (pyproject.toml)
1515
azure-keyvault-secrets==4.9.0
1616
# via pydantic-settings (pyproject.toml)
17+
boto3==1.36.17
18+
# via pydantic-settings (pyproject.toml)
19+
boto3-stubs[secretsmanager]==1.36.17
20+
# via pydantic-settings (pyproject.toml)
21+
botocore==1.36.17
22+
# via
23+
# boto3
24+
# s3transfer
25+
botocore-stubs==1.36.17
26+
# via boto3-stubs
1727
certifi==2025.1.31
1828
# via requests
1929
cffi==1.17.1
@@ -29,12 +39,18 @@ idna==3.10
2939
# via requests
3040
isodate==0.7.2
3141
# via azure-keyvault-secrets
42+
jmespath==1.0.1
43+
# via
44+
# boto3
45+
# botocore
3246
msal==1.31.1
3347
# via
3448
# azure-identity
3549
# msal-extensions
3650
msal-extensions==1.2.0
3751
# via azure-identity
52+
mypy-boto3-secretsmanager==1.36.0
53+
# via boto3-stubs
3854
portalocker==2.10.1
3955
# via msal-extensions
4056
pycparser==2.22
@@ -47,6 +63,8 @@ pyjwt[crypto]==2.10.1
4763
# via
4864
# msal
4965
# pyjwt
66+
python-dateutil==2.9.0.post0
67+
# via botocore
5068
python-dotenv==1.0.1
5169
# via pydantic-settings (pyproject.toml)
5270
pyyaml==6.0.2
@@ -55,16 +73,28 @@ requests==2.32.3
5573
# via
5674
# azure-core
5775
# msal
76+
s3transfer==0.11.2
77+
# via boto3
5878
six==1.17.0
59-
# via azure-core
79+
# via
80+
# azure-core
81+
# python-dateutil
6082
tomli==2.2.1
6183
# via pydantic-settings (pyproject.toml)
84+
types-awscrt==0.23.10
85+
# via botocore-stubs
86+
types-s3transfer==0.11.2
87+
# via boto3-stubs
6288
typing-extensions==4.12.2
6389
# via
6490
# azure-core
6591
# azure-identity
6692
# azure-keyvault-secrets
93+
# boto3-stubs
94+
# mypy-boto3-secretsmanager
6795
# pydantic
6896
# pydantic-core
6997
urllib3==2.3.0
70-
# via requests
98+
# via
99+
# botocore
100+
# requests

requirements/testing.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pytest
33
pytest-mock
44
pytest-examples
55
pytest-pretty
6+
moto[secretsmanager]

requirements/testing.txt

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,52 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.9
2+
# This file is autogenerated by pip-compile with Python 3.10
33
# by the following command:
44
#
55
# pip-compile --no-emit-index-url --output-file=requirements/testing.txt requirements/testing.in
66
#
77
black==25.1.0
88
# via pytest-examples
9+
boto3==1.36.17
10+
# via moto
11+
botocore==1.36.17
12+
# via
13+
# boto3
14+
# moto
15+
# s3transfer
16+
certifi==2025.1.31
17+
# via requests
18+
cffi==1.17.1
19+
# via cryptography
20+
charset-normalizer==3.4.1
21+
# via requests
922
click==8.1.8
1023
# via black
11-
coverage[toml]==7.6.10
24+
coverage[toml]==7.6.11
1225
# via -r requirements/testing.in
26+
cryptography==44.0.0
27+
# via moto
1328
exceptiongroup==1.2.2
1429
# via pytest
30+
idna==3.10
31+
# via requests
1532
iniconfig==2.0.0
1633
# via pytest
34+
jinja2==3.1.5
35+
# via moto
36+
jmespath==1.0.1
37+
# via
38+
# boto3
39+
# botocore
1740
markdown-it-py==3.0.0
1841
# via rich
42+
markupsafe==3.0.2
43+
# via
44+
# jinja2
45+
# werkzeug
1946
mdurl==0.1.2
2047
# via markdown-it-py
48+
moto[secretsmanager]==5.0.28
49+
# via -r requirements/testing.in
2150
mypy-extensions==1.0.0
2251
# via black
2352
packaging==24.2
@@ -30,6 +59,8 @@ platformdirs==4.3.6
3059
# via black
3160
pluggy==1.5.0
3261
# via pytest
62+
pycparser==2.22
63+
# via cffi
3364
pygments==2.19.1
3465
# via rich
3566
pytest==8.3.4
@@ -44,10 +75,26 @@ pytest-mock==3.14.0
4475
# via -r requirements/testing.in
4576
pytest-pretty==1.2.0
4677
# via -r requirements/testing.in
78+
python-dateutil==2.9.0.post0
79+
# via
80+
# botocore
81+
# moto
82+
pyyaml==6.0.2
83+
# via responses
84+
requests==2.32.3
85+
# via
86+
# moto
87+
# responses
88+
responses==0.25.6
89+
# via moto
4790
rich==13.9.4
4891
# via pytest-pretty
49-
ruff==0.9.5
92+
ruff==0.9.6
5093
# via pytest-examples
94+
s3transfer==0.11.2
95+
# via boto3
96+
six==1.17.0
97+
# via python-dateutil
5198
tomli==2.2.1
5299
# via
53100
# black
@@ -57,3 +104,12 @@ typing-extensions==4.12.2
57104
# via
58105
# black
59106
# rich
107+
urllib3==2.3.0
108+
# via
109+
# botocore
110+
# requests
111+
# responses
112+
werkzeug==3.1.3
113+
# via moto
114+
xmltodict==0.14.2
115+
# via moto

tests/test_settings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,8 +1826,7 @@ def test_builtins_settings_source_repr():
18261826
== "EnvSettingsSource(env_nested_delimiter='__', env_prefix_len=0)"
18271827
)
18281828
assert repr(DotEnvSettingsSource(BaseSettings, env_file='.env', env_file_encoding='utf-8')) == (
1829-
"DotEnvSettingsSource(env_file='.env', env_file_encoding='utf-8', "
1830-
'env_nested_delimiter=None, env_prefix_len=0)'
1829+
"DotEnvSettingsSource(env_file='.env', env_file_encoding='utf-8', env_nested_delimiter=None, env_prefix_len=0)"
18311830
)
18321831
assert (
18331832
repr(SecretsSettingsSource(BaseSettings, secrets_dir='/secrets'))

0 commit comments

Comments
 (0)