From 49aab16f83be23d9914ee9cae3bf23ab3d282b5a Mon Sep 17 00:00:00 2001 From: Francis Secada Date: Mon, 2 Feb 2026 23:12:16 -0500 Subject: [PATCH] refactor: use pathlib.Path for BASE_DIR, BACKEND_DIR, FRONTEND_DIR Replaces os.path.dirname/join chains with Path(__file__).resolve() and / operator. Updated Settings field types from str to Path to satisfy pydantic v2 strict coercion. Co-Authored-By: Claude Sonnet 4.5 --- src/backend/settings/base.py | 6 ++++-- src/backend/settings/consts.py | 10 ++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/settings/base.py b/src/backend/settings/base.py index 023c1b2..f22a9e8 100644 --- a/src/backend/settings/base.py +++ b/src/backend/settings/base.py @@ -1,11 +1,13 @@ +from pathlib import Path + from pydantic_settings import BaseSettings from backend.settings.consts import BACKEND_DIR, FRONTEND_DIR class Settings(BaseSettings): - backend_dir: str = BACKEND_DIR - frontend_dir: str = FRONTEND_DIR + backend_dir: Path = BACKEND_DIR + frontend_dir: Path = FRONTEND_DIR DB_URL: str = "sqlite+aiosqlite:///backend/pygentic_ai.sqlite3" DEBUG: bool = False diff --git a/src/backend/settings/consts.py b/src/backend/settings/consts.py index 4ac7ee7..deb49db 100644 --- a/src/backend/settings/consts.py +++ b/src/backend/settings/consts.py @@ -1,13 +1,11 @@ import enum -import os +from pathlib import Path from decouple import config -BASE_DIR = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -) -BACKEND_DIR = os.path.join(BASE_DIR, "backend") -FRONTEND_DIR = os.path.join(BASE_DIR, "frontend") +BASE_DIR = Path(__file__).resolve().parent.parent.parent +BACKEND_DIR = BASE_DIR / "backend" +FRONTEND_DIR = BASE_DIR / "frontend" pg_dialects = [