From 8077c8a7067da059e3dded2147efcb1ecd236e54 Mon Sep 17 00:00:00 2001 From: BukeLy Date: Thu, 20 Nov 2025 12:24:53 +0800 Subject: [PATCH] style: fix lint errors in test files Why this change is needed: CI reported 5 lint errors that needed to be fixed: - Unused import of 'patch' in test_dimension_mismatch.py - Unnecessary f-string prefixes without placeholders - Bare except clauses without exception type How it solves it: - Removed unused 'patch' import (auto-fixed by ruff) - Removed unnecessary f-string prefixes (auto-fixed by ruff) - Changed bare 'except:' to 'except Exception:' for proper exception handling Impact: - Code now passes all ruff lint checks - Better exception handling practices (doesn't catch SystemExit/KeyboardInterrupt) - Cleaner, more maintainable test code Testing: Verified with: uv run ruff check tests/ Result: All checks passed! --- tests/test_dimension_mismatch.py | 2 +- tests/test_e2e_multi_instance.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_dimension_mismatch.py b/tests/test_dimension_mismatch.py index 3361b621..2dd6dc1d 100644 --- a/tests/test_dimension_mismatch.py +++ b/tests/test_dimension_mismatch.py @@ -7,7 +7,7 @@ legacy collections/tables to new ones with different embedding models. """ import pytest -from unittest.mock import MagicMock, AsyncMock, patch +from unittest.mock import MagicMock, AsyncMock from lightrag.kg.qdrant_impl import QdrantVectorDBStorage from lightrag.kg.postgres_impl import PGVectorStorage diff --git a/tests/test_e2e_multi_instance.py b/tests/test_e2e_multi_instance.py index f7341777..071b0b08 100644 --- a/tests/test_e2e_multi_instance.py +++ b/tests/test_e2e_multi_instance.py @@ -1153,7 +1153,7 @@ async def test_dimension_mismatch_postgres( }, ) - print(f"✅ Legacy table created with 3 records (1536d)") + print("✅ Legacy table created with 3 records (1536d)") # Step 2: Try to initialize LightRAG with NEW model (3072d) async def embed_func_new(texts): @@ -1271,7 +1271,7 @@ async def test_dimension_mismatch_qdrant( # Delete if exists try: client.delete_collection(legacy_collection) - except: + except Exception: pass # Create legacy collection with 768d @@ -1294,7 +1294,7 @@ async def test_dimension_mismatch_qdrant( ) client.upsert(collection_name=legacy_collection, points=points, wait=True) - print(f"✅ Legacy collection created with 3 records (768d)") + print("✅ Legacy collection created with 3 records (768d)") # Step 2: Try to initialize LightRAG with NEW model (1024d) async def embed_func_new(texts): @@ -1384,7 +1384,7 @@ async def test_dimension_mismatch_qdrant( for coll in client.get_collections().collections: if "lightrag" in coll.name.lower(): client.delete_collection(coll.name) - except: + except Exception: pass