Fix Pydantic validation error by adding ClassVar annotation to DB_DIR

This commit is contained in:
Automated Action 2025-06-18 09:33:51 +00:00
parent a2ec999501
commit 21c51d4758
2 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,5 @@
from pathlib import Path from pathlib import Path
from typing import ClassVar
from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic_settings import BaseSettings, SettingsConfigDict
@ -18,7 +19,7 @@ class Settings(BaseSettings):
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
# Database settings # Database settings
DB_DIR = Path("/app") / "storage" / "db" DB_DIR: ClassVar[Path] = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite" SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"

View File

@ -1,6 +1,6 @@
import sys import sys
from pathlib import Path
from logging.config import fileConfig from logging.config import fileConfig
from pathlib import Path
from alembic import context from alembic import context
from sqlalchemy import engine_from_config, pool from sqlalchemy import engine_from_config, pool
@ -9,7 +9,8 @@ from sqlalchemy import engine_from_config, pool
project_root = Path(__file__).parent.parent project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root)) sys.path.insert(0, str(project_root))
from app.db.base import Base # Import after adding to path to avoid ModuleNotFoundError
from app.db.base import Base # noqa: E402
# this is the Alembic Config object, which provides # this is the Alembic Config object, which provides
# access to the values within the .ini file in use. # access to the values within the .ini file in use.