From 2638cf1a35d9e34204d7d919fbbca5288f6acdbb Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Mon, 6 Jul 2026 13:24:55 -0400 Subject: [PATCH] style(tests): hoist test_api_tags grounding imports to module level (ruff I001) CI ruff flagged the in-function import block; move them to the top mirroring test_ml_suggestions.py's import line, which ruff already accepts. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01CDgx8bQS5YrGRK76v8HUnM --- tests/test_api_tags.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/test_api_tags.py b/tests/test_api_tags.py index 31e3558..00f3b83 100644 --- a/tests/test_api_tags.py +++ b/tests/test_api_tags.py @@ -1,4 +1,8 @@ import pytest +from sqlalchemy import select + +from backend.app.models import ImageRecord, ImageRegion, MLSettings, TagHead, TagKind +from backend.app.services.tag_service import TagService pytestmark = pytest.mark.integration @@ -104,13 +108,6 @@ async def test_applied_tag_grounding_returns_winning_region(client, db): # Hovering an applied chip fetches the crop that best explains the tag. Here # the whole-image vector is orthogonal to the head but a concept crop aligns, # so the crop wins the max-over-bag → grounding is that region's box. - from sqlalchemy import select - - from backend.app.models import ( - ImageRecord, ImageRegion, MLSettings, TagHead, TagKind, - ) - from backend.app.services.tag_service import TagService - ver = (await db.execute( select(MLSettings).where(MLSettings.id == 1) )).scalar_one().embedder_model_version @@ -148,9 +145,6 @@ async def test_applied_tag_grounding_returns_winning_region(client, db): async def test_applied_tag_grounding_no_head(client, db): # A tag with no head can't be localized → has_head False, grounding null; the # chip shows no overlay. Validates the response contract the frontend reads. - from backend.app.models import ImageRecord, TagKind - from backend.app.services.tag_service import TagService - img = ImageRecord( path="/images/grchip2.jpg", sha256="gd" * 32, size_bytes=1, mime="image/jpeg", width=1, height=1, origin="imported_filesystem",