Skip to content

fix(extract): resolve Python imports through unchanged initializers - #5679

Open
Max17190 wants to merge 1 commit into
Graphify-Labs:v8from
Max17190:fix/incremental-python-package-reexports
Open

Max17190 wants to merge 1 commit into
Graphify-Labs:v8from
Max17190:fix/incremental-python-package-reexports

Conversation

@Max17190

@Max17190 Max17190 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Why

On an incremental update, Python re-export facts came only from an __init__.py in the parsed batch. So from lib import f in an edited file stopped at the unchanged lib/__init__.py, and the file lost its imports and calls through the package until a full rebuild. Fixes #5676.

Summary

_collect_python_reexport_context reads export facts from live unchanged initializers that the batch's imports reach, and follows re-exports through nested initializers. Unchanged files add resolver facts only, never edges. This matches the JS/TS barrel context from #5595, and ARCHITECTURE.md now says so.

On Django, adding a comment to tests/admin_views/tests.py kept 431 of the file's 1121 import and call edges on v8, and keeps all 1121 with this change. Cold builds do not run the new code, and a cold build of Graphify's own source matches v8 byte for byte.

Limitations: the same Django edit still misses 253 class level uses edges. v8 misses them too, and they do not go through initializers.

Test plan

python -m pytest tests -q -n 4 --dist loadfile   # 12639 passed
python -m pytest tests/test_python_incremental_reexports.py -q   # 2 passed; both fail on v8
uv run ruff check .                              # passes
uv run pyright --pythonpath .venv/bin/python     # same diagnostics as v8
uv run python -m tools.skillgen --check          # 134 artifacts match
graphify update .   # Django, incremental after a one line edit, compared with the cold build
  • Read CONTRIBUTING.md
  • AI help disclosed in the commit trailer

Only a parsed package __init__.py yields Python re-export facts. An
incremental batch that holds `from pkg import f` without the unchanged
pkg/__init__.py could not follow `f` to its defining module, so the
edited file lost its imports and calls through the package until a full
rebuild.

Read export facts from live unchanged initializers that the batch's
imports reach, and follow re-exports through nested initializers. This
matches the existing JS/TS barrel context from Graphify-Labs#5595.

Fixes Graphify-Labs#5676

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Max17190
Max17190 requested a review from safishamsi as a code owner December 1, 2026 06:55
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Thanks for the pull request, @Max17190. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Dec 1, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Looks safe to merge · Merge confidence 5/5

No issues reported · High impact

Incremental symbol resolution now reads export facts from unchanged Python package initializers and follows re-exports into subpackage initializers.

What this review covered
  • We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
  • 2 of 2 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 4755 functions depend on this change
  • 2 functions became more coupled. _collect_python_symbol_resolution_facts() (3 callers), _augment_symbol_resolution_edges() (2 callers).
  • 666 of 666 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed 5c0ea1f

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incremental update drops Python imports and calls that go through an unchanged package __init__.py

1 participant