From 9fcfb9ee1bf4bf46a7261757f1d3ce5b1118ae1e Mon Sep 17 00:00:00 2001 From: AndresL230 <190146319+AndresL230@users.noreply.github.com> Date: Wed, 8 Jul 2026 02:25:47 -0400 Subject: [PATCH] chore(lint): fix ruff violations in RAG scripts unblocking main CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main's CI (Backend job) has been red since the RAG pipeline scripts landed (~Jul 3): 8 un-baselined ruff errors caused ruff check . to exit 1, skipping pytest. Because main isn't a protected branch, merges proceeded through the red and it went unnoticed — and every open PR's Backend job inherited the failure via the pull_request merge check. Fixes (behavior-preserving): - benchmark_rag.py: drop unused import os; noqa: E402 on the two intentional post-sys.path imports; drop unused chunk_results binding (keeps the side-effecting run_chunk_tests call). - ingest_catalog.py: noqa: E402 on the post-sys.path import; drop stray f-prefix on a placeholder-less string. - scrape_bu_catalog.py: drop unused import sys; drop unused school_courses binding (keeps the side-effecting scrape_school call). Verified locally: ruff 0.15.20 check . -> All checks passed. Co-Authored-By: Claude Opus 4.8 --- backend/scripts/benchmark_rag.py | 7 +++---- backend/scripts/ingest_catalog.py | 4 ++-- backend/scripts/scrape_bu_catalog.py | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/backend/scripts/benchmark_rag.py b/backend/scripts/benchmark_rag.py index e198a55f..08584c1e 100644 --- a/backend/scripts/benchmark_rag.py +++ b/backend/scripts/benchmark_rag.py @@ -8,7 +8,6 @@ """ import argparse -import os import sys import textwrap from pathlib import Path @@ -23,8 +22,8 @@ from dotenv import load_dotenv load_dotenv(Path(__file__).parent.parent / ".env.staging") # use staging DB -from routes.learn import _get_catalog_chunk -from services.gemini_service import call_gemini +from routes.learn import _get_catalog_chunk # noqa: E402 +from services.gemini_service import call_gemini # noqa: E402 # ── Ground-truth test cases ──────────────────────────────────────────────────── @@ -519,7 +518,7 @@ def main() -> None: if filter_course: print(f"Filtered to: {filter_course}") - chunk_results = run_chunk_tests(cases) + run_chunk_tests(cases) if not args.chunks_only: llm_results = run_llm_tests(cases, filter_course=filter_course) diff --git a/backend/scripts/ingest_catalog.py b/backend/scripts/ingest_catalog.py index 84eb37a3..d2457ade 100644 --- a/backend/scripts/ingest_catalog.py +++ b/backend/scripts/ingest_catalog.py @@ -27,7 +27,7 @@ load_dotenv(Path(__file__).parent.parent / ".env") sys.path.insert(0, str(Path(__file__).parent.parent)) -from db.connection import table +from db.connection import table # noqa: E402 # ── Config ───────────────────────────────────────────────────────────────────── @@ -144,7 +144,7 @@ def main() -> None: rec["embedding"] = vec # Upsert to Supabase in batches of BATCH_SIZE - print(f"\nUpserting to course_chunks...") + print("\nUpserting to course_chunks...") db = table("course_chunks") inserted = 0 diff --git a/backend/scripts/scrape_bu_catalog.py b/backend/scripts/scrape_bu_catalog.py index b7112b48..52502021 100644 --- a/backend/scripts/scrape_bu_catalog.py +++ b/backend/scripts/scrape_bu_catalog.py @@ -13,7 +13,6 @@ import asyncio import json import re -import sys from datetime import datetime, timezone from pathlib import Path from typing import Optional @@ -349,7 +348,7 @@ def save_checkpoint(batch: list[dict]) -> None: for school in SCHOOLS: print(f"\n>> {school}", flush=True) before = len(all_courses) - school_courses = await scrape_school(client, school, seen_urls, on_batch=save_checkpoint) + await scrape_school(client, school, seen_urls, on_batch=save_checkpoint) print(f" [{school}] +{len(all_courses) - before} -> total {len(all_courses)}", flush=True) elapsed = (datetime.now(timezone.utc) - start).total_seconds()