Skip to content

Commit

Permalink
settings-library
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Dec 3, 2024
1 parent 0b5e311 commit a2ae61b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
13 changes: 9 additions & 4 deletions packages/settings-library/src/settings_library/aws_s3_cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from typing import Annotated

from pydantic import Field

from .base import BaseCustomSettings
from .s3 import S3Settings


class AwsS3CliSettings(BaseCustomSettings):
AWS_S3_CLI_S3: S3Settings = Field(
default=None,
description="These settings intentionally do not use auto_default_from_env=True because we might want to turn them off if RClone is enabled.",
)
AWS_S3_CLI_S3: Annotated[
S3Settings,
Field(
description="These settings intentionally do not use auto_default_from_env=True "
"because we might want to turn them off if RClone is enabled.",
),
]
2 changes: 1 addition & 1 deletion packages/settings-library/src/settings_library/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def prepare_field_value(
and field.default is None
and prepared_value == _MARKED_AS_UNSET
):
prepared_value = field.default_factory()
prepared_value = field.default_factory() # type: ignore[call-arg]
return prepared_value


Expand Down
7 changes: 5 additions & 2 deletions packages/settings-library/tests/test_base_w_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
from collections.abc import Callable

import pytest
from pydantic import AliasChoices, Field, ValidationError
from pydantic import AliasChoices, Field, ValidationError, __version__
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_envfile
from settings_library.base import BaseCustomSettings, DefaultFromEnvFactoryError
from settings_library.basic_types import PortInt

pydantic_vtag = ".".join(__version__.split(".")[:2])


#
# NOTE: Pydantic models are returned by function-scoped fixture such that every
# test starts with a fresh Model class (notice that pydanctic classes involve meta-operations
Expand Down Expand Up @@ -174,7 +177,7 @@ def test_parse_from_individual_envs(
"loc": ("WEBSERVER_POSTGRES",),
"msg": "Field required",
"type": "missing",
"url": "https://errors.pydantic.dev/2.9/v/missing",
"url": f"https://errors.pydantic.dev/{pydantic_vtag}/v/missing",
}

s2 = S2()
Expand Down

0 comments on commit a2ae61b

Please sign in to comment.