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!
This commit is contained in:
parent
5180c1e395
commit
8077c8a706
2 changed files with 5 additions and 5 deletions
|
|
@ -7,7 +7,7 @@ legacy collections/tables to new ones with different embedding models.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
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.qdrant_impl import QdrantVectorDBStorage
|
||||||
from lightrag.kg.postgres_impl import PGVectorStorage
|
from lightrag.kg.postgres_impl import PGVectorStorage
|
||||||
|
|
|
||||||
|
|
@ -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)
|
# Step 2: Try to initialize LightRAG with NEW model (3072d)
|
||||||
async def embed_func_new(texts):
|
async def embed_func_new(texts):
|
||||||
|
|
@ -1271,7 +1271,7 @@ async def test_dimension_mismatch_qdrant(
|
||||||
# Delete if exists
|
# Delete if exists
|
||||||
try:
|
try:
|
||||||
client.delete_collection(legacy_collection)
|
client.delete_collection(legacy_collection)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create legacy collection with 768d
|
# 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)
|
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)
|
# Step 2: Try to initialize LightRAG with NEW model (1024d)
|
||||||
async def embed_func_new(texts):
|
async def embed_func_new(texts):
|
||||||
|
|
@ -1384,7 +1384,7 @@ async def test_dimension_mismatch_qdrant(
|
||||||
for coll in client.get_collections().collections:
|
for coll in client.get_collections().collections:
|
||||||
if "lightrag" in coll.name.lower():
|
if "lightrag" in coll.name.lower():
|
||||||
client.delete_collection(coll.name)
|
client.delete_collection(coll.name)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue