Fix #666: Probe submodules for python package imports#676
Conversation
|
✅ Health: 7.6 (unchanged) 🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)
🔥 Hotspot touched (1)
🔗 Hidden coupling (1 file)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-03 20:36 UTC |
|
Thanks for tackling #666. Two things are blocking merge. CI is red because the two new tests don't run. They build The dead-code regression that #666 asked for is also missing. Nothing yet proves a router imported only at the package level stops being flagged as unreachable. A small end-to-end test on that shape would lock it in. Two smaller notes. Namespace packages (no Happy to re-review once CI is green. |
Summary
This PR fixes the false-positive
unreachable_filereports on Python router modules caused by the resolver missing submodules when they are imported via a package__init__.py.The root cause was that
resolve_python_importwould resolve statements likefrom repowise.server.routers import workspacestrictly torepowise/server/routers/__init__.py, meaning the submodules themselves never received inbound edges and were falsely flagged by the dead-code analyzer within_degree=0.Changes:
resolve_python_import_allhelper function inrepowise.core.ingestion.resolvers.python.resolve_python_import_allresolves the base package, then properly iterates over theImport.imported_namesto probe for<name>.pyand<name>/__init__.pysubmodules in the package directory._resolve_importsingraph/builder.pyto route Python resolutions through this new function, appending missing edges.Related Issues
Fixes #666
Test Plan
pytest)ruff check .)npm run build) (if frontend changes)Added a dedicated regression test (
test_python_resolver.py) ensuringresolve_python_import_allproperly identifies and returns submodule file paths when a module uses thefrom pkg import submodule1, submodule2format.Checklist