Fix Pydantic v2 configuration for application startup

- Added proper type annotations for DB_DIR using ClassVar[Path]
- Updated Settings class to use model_config instead of deprecated Config class
- Fixed PydanticUserError for non-annotated attributes in settings
- Application should now start properly with uvicorn
This commit is contained in:
Automated Action 2025-06-17 05:58:42 +00:00
parent 7cef391c68
commit 40981760c9

View File

@ -1,5 +1,6 @@
import os import os
from pathlib import Path from pathlib import Path
from typing import ClassVar
from pydantic_settings import BaseSettings from pydantic_settings import BaseSettings
@ -16,12 +17,13 @@ class Settings(BaseSettings):
VERSION: str = "0.1.0" VERSION: str = "0.1.0"
# SQLite Database settings # SQLite 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"
class Config: model_config = {
case_sensitive = True "case_sensitive": True,
env_file = os.path.join(BASE_DIR, ".env") "env_file": os.path.join(BASE_DIR, ".env"),
}
settings = Settings() settings = Settings()