Skip to content

♻️ Replace email types from str to EmailStr in config.py #1492

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

Merged
merged 3 commits into from
Feb 18, 2025
Merged
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
12 changes: 5 additions & 7 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import (
AnyUrl,
BeforeValidator,
EmailStr,
HttpUrl,
PostgresDsn,
computed_field,
Expand Down Expand Up @@ -74,9 +75,8 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn:
SMTP_HOST: str | None = None
SMTP_USER: str | None = None
SMTP_PASSWORD: str | None = None
# TODO: update type to EmailStr when sqlmodel supports it
EMAILS_FROM_EMAIL: str | None = None
EMAILS_FROM_NAME: str | None = None
EMAILS_FROM_EMAIL: EmailStr | None = None
EMAILS_FROM_NAME: EmailStr | None = None

@model_validator(mode="after")
def _set_default_emails_from(self) -> Self:
Expand All @@ -91,10 +91,8 @@ def _set_default_emails_from(self) -> Self:
def emails_enabled(self) -> bool:
return bool(self.SMTP_HOST and self.EMAILS_FROM_EMAIL)

# TODO: update type to EmailStr when sqlmodel supports it
EMAIL_TEST_USER: str = "[email protected]"
# TODO: update type to EmailStr when sqlmodel supports it
FIRST_SUPERUSER: str
EMAIL_TEST_USER: EmailStr = "[email protected]"
FIRST_SUPERUSER: EmailStr
FIRST_SUPERUSER_PASSWORD: str

def _check_default_secret(self, var_name: str, value: str | None) -> None:
Expand Down
Loading