From 2c173c700a7462d7256dbb5192aa0c1bd7d8e44e Mon Sep 17 00:00:00 2001 From: Ho1yShif Date: Mon, 13 Jul 2026 09:52:27 -0700 Subject: [PATCH] Fix unsorted imports, apply ruff format, activate pre-commit hook Sort imports in three files to satisfy ruff's I001 (force-sort-within-sections), which was failing CI, and apply ruff format to a test file whose multi-line signatures fit within the 100-char limit. Also remove --exit-zero from the ruff pre-commit hook so unfixable lint errors block the commit locally, mirroring CI's strict `ruff check .`. Root cause: the pre-commit config existed but the git hook was never installed (`pre-commit install`), so lint-dirty commits reached CI unchecked. The format issue was latent because CI stops at the failing `ruff check` step before reaching `ruff format --check`. Co-Authored-By: Claude Opus 4.8 (1M context) --- .pre-commit-config.yaml | 5 +++-- deeptutor/services/demo/rate_limiter.py | 2 +- tests/api/test_settings_router_secrets.py | 10 +++------- tests/services/demo/test_session_store_demo.py | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5dfec8c..6e41fb6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,8 +43,9 @@ repos: rev: v0.14.7 hooks: - id: ruff - # Added --quiet to suppress logs; --exit-zero makes it a "soft fail" if desired - args: [--fix, --quiet, --exit-zero] + # --fix auto-repairs what it can; without --exit-zero, unfixable lint + # errors block the commit, mirroring CI's strict `ruff check .` + args: [--fix, --quiet] - id: ruff-format args: [--quiet] diff --git a/deeptutor/services/demo/rate_limiter.py b/deeptutor/services/demo/rate_limiter.py index 0a6cecda..3ee83372 100644 --- a/deeptutor/services/demo/rate_limiter.py +++ b/deeptutor/services/demo/rate_limiter.py @@ -45,9 +45,9 @@ from __future__ import annotations +from dataclasses import dataclass import os import time -from dataclasses import dataclass from typing import Callable _TRUTHY = {"1", "true", "yes", "on"} diff --git a/tests/api/test_settings_router_secrets.py b/tests/api/test_settings_router_secrets.py index 0a787919..745c4fee 100644 --- a/tests/api/test_settings_router_secrets.py +++ b/tests/api/test_settings_router_secrets.py @@ -5,8 +5,8 @@ import json from pathlib import Path -import pytest from fastapi.testclient import TestClient +import pytest from deeptutor.api import main as api_main from deeptutor.api.routers import settings as settings_router @@ -37,9 +37,7 @@ def _seed(svc: ModelCatalogService) -> None: svc.save(catalog) -def test_get_catalog_has_no_key_but_has_indicators( - client, tmp_catalog, monkeypatch -) -> None: +def test_get_catalog_has_no_key_but_has_indicators(client, tmp_catalog, monkeypatch) -> None: monkeypatch.setenv("OPENAI_API_KEY", "sk-live") _seed(tmp_catalog) @@ -53,9 +51,7 @@ def test_get_catalog_has_no_key_but_has_indicators( assert profile["api_key_env_var"] == "OPENAI_API_KEY" -def test_get_catalog_indicator_false_when_env_unset( - client, tmp_catalog, monkeypatch -) -> None: +def test_get_catalog_indicator_false_when_env_unset(client, tmp_catalog, monkeypatch) -> None: monkeypatch.delenv("OPENAI_API_KEY", raising=False) _seed(tmp_catalog) diff --git a/tests/services/demo/test_session_store_demo.py b/tests/services/demo/test_session_store_demo.py index f100d608..96c31144 100644 --- a/tests/services/demo/test_session_store_demo.py +++ b/tests/services/demo/test_session_store_demo.py @@ -13,9 +13,9 @@ import pytest import deeptutor.services.demo.rate_limiter as rate_limiter -import deeptutor.services.session.sqlite_store as sqlite_store from deeptutor.services.path_service import PathService from deeptutor.services.session import get_session_store +import deeptutor.services.session.sqlite_store as sqlite_store from deeptutor.services.session.sqlite_store import get_sqlite_session_store