From 5130ce95eba483b1b164e8b2b701623a5958317d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Loipf=C3=BChrer?= Date: Sat, 26 Aug 2023 18:34:50 +0200 Subject: [PATCH] feat(core): upgrade to latest fastapi --- abrechnung/config.py | 22 +++++++++++----------- abrechnung/http/routers/accounts.py | 2 +- abrechnung/http/routers/common.py | 2 +- abrechnung/http/routers/groups.py | 2 +- pyproject.toml | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/abrechnung/config.py b/abrechnung/config.py index d76637e3..e93ff579 100644 --- a/abrechnung/config.py +++ b/abrechnung/config.py @@ -13,23 +13,23 @@ class ServiceConfig(BaseModel): class DemoConfig(BaseModel): - enabled = False - wipe_interval = timedelta(hours=1) + enabled: bool = False + wipe_interval: timedelta = timedelta(hours=1) class ApiConfig(BaseModel): secret_key: str host: str port: int - id = "default" - max_uploadable_file_size = 1024 - enable_cors = True - access_token_validity = timedelta(hours=1) + id: str = "default" + max_uploadable_file_size: int = 1024 + enable_cors: bool = True + access_token_validity: timedelta = timedelta(hours=1) class RegistrationConfig(BaseModel): - enabled = False - allow_guest_users = False + enabled: bool = False + allow_guest_users: bool = False valid_email_domains: Optional[List[str]] = None @@ -49,7 +49,7 @@ class AuthConfig(BaseModel): address: str host: str port: int - mode = "smtp" # oneof "local" "smtp-ssl" "smtp-starttls" "smtp" + mode: str = "smtp" # oneof "local" "smtp-ssl" "smtp-starttls" "smtp" auth: Optional[AuthConfig] = None @@ -59,8 +59,8 @@ class Config(BaseModel): database: DatabaseConfig email: EmailConfig # in case all params are optional this is needed to make the whole section optional - demo = DemoConfig() - registration = RegistrationConfig() + demo: DemoConfig = DemoConfig() + registration: RegistrationConfig = RegistrationConfig() def read_config(config_path: Path) -> Config: diff --git a/abrechnung/http/routers/accounts.py b/abrechnung/http/routers/accounts.py index 1344a810..c1e9708c 100644 --- a/abrechnung/http/routers/accounts.py +++ b/abrechnung/http/routers/accounts.py @@ -40,7 +40,7 @@ class BaseAccountPayload(BaseModel): date_info: Optional[date] = None tags: Optional[List[str]] = None owning_user_id: Optional[int] = None - clearing_shares: ClearingShares + clearing_shares: ClearingShares = None class CreateAccountPayload(BaseAccountPayload): diff --git a/abrechnung/http/routers/common.py b/abrechnung/http/routers/common.py index 96758a79..2a998843 100644 --- a/abrechnung/http/routers/common.py +++ b/abrechnung/http/routers/common.py @@ -16,7 +16,7 @@ class VersionResponse(BaseModel): patch_version: int class Config: - schema_extra = { + json_schema_extra = { "example": { "version": "1.3.2", "major_version": 1, diff --git a/abrechnung/http/routers/groups.py b/abrechnung/http/routers/groups.py index 1796a2d0..fcb76ebe 100644 --- a/abrechnung/http/routers/groups.py +++ b/abrechnung/http/routers/groups.py @@ -79,7 +79,7 @@ class GroupPayload(BaseModel): name: str description: str = "" currency_symbol: str - add_user_account_on_join = False + add_user_account_on_join: bool = False terms: str = "" diff --git a/pyproject.toml b/pyproject.toml index 7319a174..c2c49e91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,8 @@ classifiers = [ ] requires-python = ">=3.9" dependencies = [ - "fastapi~=0.88", + "fastapi~=0.102", + "pydantic[email]~=2.3.0", "uvicorn[standard]~=0.20", "python-jose[cryptography]~=3.3", "asyncpg~=0.27", @@ -28,7 +29,6 @@ dependencies = [ "websockets~=10.4", "python-multipart~=0.0.5", "PyYAML~=6.0", - "email-validator~=1.3", "schema~=0.7", ]