fix(pgvector): resolve F401 unused import for psycopg - #366
Conversation
Replace direct import with importlib.util.find_spec() check as recommended by ruff. Add ValueError handling for mocked modules in tests.
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
Replaces the import-based psycopg availability check in PGVectorRetriever.__init__ with importlib.util.find_spec, so the missing-dependency ImportError fires without actually importing the module. Swallows the ValueError find_spec raises for modules mocked into sys.modules, letting tests patch psycopg without tripping the check.
No blocking issues surfaced. 6 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 17 functions depend on the 12 functions this change touches.
Health — grade A; no new coupling hotspots.
Verification — 17 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 17 function(s) in the blast radius were not formally verified this run
|
🎉 Congratulations @devhub02! Your pull request has been successfully merged into main. 🚀 Thank you for contributing to OpenAgentHQ and helping improve the project. We truly appreciate your contribution and hope to see you back with more amazing PRs! Happy Open Sourcing! ❤️ |
Summary
Fixes F401 lint error in
pgvector.pywherepsycopgwas imported but unused.Changes
import psycopgwithimportlib.util.find_spec("psycopg")check (ruff's recommended approach for F401)ValueErrorhandling for mocked modules in tests (wherepsycopgis patched intosys.modules)Testing
ruff check openagent_eval/providers/retrievers/pgvector.py- All checks passpytest tests/unit/test_providers/test_pgvector_retriever.py -v- All 4 tests passRelated
Fixes #306