diff --git a/.gitignore b/.gitignore index 48f43e76..d8ab9c17 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ __pypackages__/ #mypyr .mypy_cache/ + +# macos +.DS_Store diff --git a/tad/core/config.py b/tad/core/config.py index 51e82e94..3fe570bc 100644 --- a/tad/core/config.py +++ b/tad/core/config.py @@ -1,6 +1,6 @@ import secrets import warnings -from typing import Annotated, Any, Literal, Self +from typing import Annotated, Any, Literal, TypeVar from pydantic import ( AnyUrl, @@ -13,6 +13,9 @@ from tad.core.exceptions import SettingsError +# Self type is not available in Python 3.10 so create our own with TypeVar +SelfSettings = TypeVar("SelfSettings", bound="Settings") + def parse_cors(v: Any) -> list[str] | str: if isinstance(v, str) and not v.startswith("["): @@ -81,14 +84,14 @@ def _check_default_secret(self, var_name: str, value: str | None) -> None: raise SettingsError(message) @model_validator(mode="after") - def _enforce_non_default_secrets(self) -> Self: + def _enforce_non_default_secrets(self: SelfSettings) -> SelfSettings: self._check_default_secret("SECRET_KEY", self.SECRET_KEY) self._check_default_secret("APP_DATABASE_PASSWORD", self.APP_DATABASE_PASSWORD) return self @model_validator(mode="after") - def _enforce_database_rules(self) -> Self: + def _enforce_database_rules(self: SelfSettings) -> SelfSettings: if self.ENVIRONMENT != "local" and self.APP_DATABASE_SCHEME == "sqlite": raise SettingsError("SQLite is not supported in production") # noqa: TRY003 return self diff --git a/tad/tests/conftest.py b/tad/tests/conftest.py index 2115d941..8bc5bfe8 100644 --- a/tad/tests/conftest.py +++ b/tad/tests/conftest.py @@ -6,9 +6,8 @@ from tad.main import app -# todo(berry): add database fixtures - +# todo(berry): add database fixtures @pytest.fixture(scope="module") def client() -> Generator[TestClient, None, None]: with TestClient(app, raise_server_exceptions=True) as c: