diff --git a/backend/Makefile b/backend/Makefile index 85cf11b..640390b 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -1,5 +1,13 @@ .PHONY: help lint lint-fix format format-check type-check test test-cov validate clean install-dev +# Virtual environment binaries +VENV_BIN = .venv/bin +PYTHON = $(VENV_BIN)/python +PIP = $(VENV_BIN)/pip +PYTEST = $(VENV_BIN)/pytest +RUFF = $(VENV_BIN)/ruff +MYPY = $(VENV_BIN)/mypy + # Default target help: @echo "๐Ÿš€ FastAPI Backend - Development Commands" @@ -26,23 +34,23 @@ help: lint: @echo "๐Ÿ” Running Ruff linter..." - @ruff check app/ tests/ + @$(RUFF) check app/ tests/ lint-fix: @echo "๐Ÿ”ง Running Ruff linter with auto-fix..." - @ruff check --fix app/ tests/ + @$(RUFF) check --fix app/ tests/ format: @echo "โœจ Formatting code with Ruff..." - @ruff format app/ tests/ + @$(RUFF) format app/ tests/ format-check: @echo "๐Ÿ“‹ Checking code formatting..." - @ruff format --check app/ tests/ + @$(RUFF) format --check app/ tests/ type-check: @echo "๐Ÿ”Ž Running mypy type checking..." - @mypy app/ + @$(MYPY) app/ validate: lint format-check type-check @echo "โœ… All quality checks passed!" @@ -53,11 +61,11 @@ validate: lint format-check type-check test: @echo "๐Ÿงช Running tests..." - @IS_TEST=True pytest + @IS_TEST=True PYTHONPATH=. $(PYTEST) test-cov: @echo "๐Ÿงช Running tests with coverage..." - @IS_TEST=True pytest --cov=app --cov-report=term-missing --cov-report=html -n 0 + @IS_TEST=True PYTHONPATH=. $(PYTEST) --cov=app --cov-report=term-missing --cov-report=html -n 0 @echo "๐Ÿ“Š Coverage report generated in htmlcov/index.html" # ============================================================================ @@ -66,7 +74,7 @@ test-cov: install-dev: @echo "๐Ÿ“ฆ Installing development dependencies..." - @pip install -r requirements.txt + @$(PIP) install -r requirements.txt @echo "โœ… Development environment ready!" clean: diff --git a/backend/app/crud/session.py b/backend/app/crud/session.py index 528a7ce..efa139b 100755 --- a/backend/app/crud/session.py +++ b/backend/app/crud/session.py @@ -309,7 +309,7 @@ class CRUDSession(CRUDBase[UserSession, SessionCreate, SessionUpdate]): # Use bulk DELETE with WHERE clause - single query stmt = delete(UserSession).where( and_( - not UserSession.is_active, + UserSession.is_active == False, # noqa: E712 UserSession.expires_at < now, UserSession.created_at < cutoff_date, ) @@ -356,7 +356,7 @@ class CRUDSession(CRUDBase[UserSession, SessionCreate, SessionUpdate]): stmt = delete(UserSession).where( and_( UserSession.user_id == uuid_obj, - not UserSession.is_active, + UserSession.is_active == False, # noqa: E712 UserSession.expires_at < now, ) ) diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 792110e..29104ba 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -139,6 +139,10 @@ plugins = ["pydantic.mypy"] module = "alembic.*" ignore_errors = true +[[tool.mypy.overrides]] +module = "app.alembic.*" +ignore_errors = true + [[tool.mypy.overrides]] module = "sqlalchemy.*" ignore_missing_imports = true @@ -171,6 +175,10 @@ ignore_missing_imports = true module = "apscheduler.*" ignore_missing_imports = true +[[tool.mypy.overrides]] +module = "starlette.*" +ignore_missing_imports = true + # ============================================================================ # Pydantic mypy plugin configuration # ============================================================================