Repository navigation
fix(package-resolver): return .py file for flat single-file packages instead of site-packages dir - #1586
Conversation
…instead of site-packages dir Signed-off-by: Aloys Jehwin <[email protected]>
|
@AloysJehwin is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
sys.path.insert of an absolute /home/<user>/... path only works on the machine it was written on, and shadows the package under test everywhere else. The repo's own venv already puts src on the path.
Shashankss1205
left a comment
There was a problem hiding this comment.
Verified locally: trial-merged with #1580, #1583, #1590 and #1591 — full suite green (1153 passed, 7 skipped).
Correct fix for #1528, and the narrow guard is the right call: special-casing only site-packages/dist-packages fixes the dangerous case without changing how ordinary packages resolve.
six -> .../site-packages/six.py # was site-packages/
typing_extensions -> .../site-packages/typing_extensions.py
packaging -> .../site-packages/packaging # unchanged
neo4j -> .../site-packages/neo4j # unchanged
One change I pushed to your branch rather than bouncing it back: the test had
sys.path.insert(0, '/home/aloysjehwin/CodeGraphContext/src')That only works on your machine, and on any other it shadows the package under test with whatever happens to be at that path. Removed — the repo's venv already puts src on the path, and the test passes without it. Everything else is yours. Thanks!
Ten PRs since 0.5.6 — mostly parser correctness, all with regression tests. Parsers - Ruby nested classes no longer delete their parent; method parameters extracted at all (#1523, #1527, #1581) - C/C++ functions returning a pointer or reference are extracted, and registered in pre_scan so they resolve as call targets (#1524, #1582) - C# fields and locals parsed, restoring receiver-type inference for `var x = new T(); x.M();` (#1525, #1584) - JavaScript destructured, array and rest parameters extracted, recording the binding names rather than a placeholder (#1527, #1591) Queries and analysis - Five defects that returned wrong answers without erroring: inflated repository stats, misattributed callers, discarded graph_name, count(*) after OPTIONAL MATCH, an ignored tool argument (#1577) - Dead-code detection made correct and self-consistent, including the JS module-level false positive (#600, #1559, #1578) Indexing - add_package_to_graph on a flat module no longer indexes the whole virtualenv (#1528, #1586) - SCIP job progress no longer exceeds 100% (#1535, #1583) Docs and tests - Database Options table columns realigned (#1590) - MCP tool definition contract validation (#1580) Co-authored-by: Claude Fable 5 <[email protected]>
Fixes #1528
_get_python_package_pathwas returningmodule_file.parentfor every non-stdlib, non-__init__.pymodule. For flat single-file packages likesix.pyandtyping_extensions.py, the parent issite-packagesitself — soadd_package_to_graphwould launchbuild_graph_from_path_asyncon the entire dependency tree.The fix adds a guard: if the parent directory is named
site-packagesordist-packages, return the file directly instead of its parent. Normal namespace packages (with their own subdirectory) are unaffected.Added two regression tests. Both pass.