From bff5c533721f1dd1bbc3bb7982dd73c00997fd84 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Tue, 10 Jun 2025 15:02:39 +0000 Subject: [PATCH] Fix Pydantic error in Settings class - Add ClassVar type annotation to DB_DIR field - Move directory creation logic outside of Settings class - Update config class to use model_config dict format for Pydantic v2 - Fix database migration error related to non-annotated attribute --- app/core/config.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/core/config.py b/app/core/config.py index eaf69ed..7f4f7e5 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -1,8 +1,13 @@ """Application configuration settings.""" from pathlib import Path +from typing import ClassVar from pydantic_settings import BaseSettings +# Create database directory +DB_DIR = Path("/app") / "storage" / "db" +DB_DIR.mkdir(parents=True, exist_ok=True) + class Settings(BaseSettings): """Application settings.""" @@ -12,14 +17,13 @@ class Settings(BaseSettings): API_V1_STR: str = "/api/v1" # Database - DB_DIR = Path("/app") / "storage" / "db" - DB_DIR.mkdir(parents=True, exist_ok=True) + DB_DIR: ClassVar[Path] = DB_DIR SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite" - class Config: - """Config class for Settings.""" - case_sensitive = True - env_file = ".env" + model_config = { + "case_sensitive": True, + "env_file": ".env", + } settings = Settings() \ No newline at end of file