Skip to content

Allow report_change to skip static object analysis - #970

Open
wozhenbang2004 wants to merge 5 commits into
python-rope:masterfrom
wozhenbang2004:patch-1
Open

wozhenbang2004 wants to merge 5 commits into
python-rope:masterfrom
wozhenbang2004:patch-1

Conversation

@wozhenbang2004

Copy link
Copy Markdown

Description

Editor integrations that provide unsaved buffers through fscommands.read() need to refresh Rope's cached modules after buffer edits. report_change() already notifies the resource observers, but it also runs static object analysis when automatic_soa is enabled. That makes using it on every keystroke unnecessarily expensive.

Add a keyword-only perform_soa=True option. An editor can call report_change(..., perform_soa=False) to refresh the caches and defer analysis. Existing calls retain their behavior, and the option leaves the project's automatic_soa preference unchanged. The library documentation explains how to analyze the whole module or retain the last analyzed contents after several deferred edits.

This follows the suggested API direction in #925. The broader filesystem work in #911 remains separate; this change only adds the notification-only report_change() path and its documentation.

Related to #925.

Three new tests use real module caches and inferred objects to cover an unsaved buffer update, skipping analysis followed by the existing default analysis, and respecting automatic_soa=False. They fail on the base because the new keyword is unavailable, then pass with this change.

Validation on Python 3.12.14:

  • The focused report_change tests pass: 4 passed.
  • Project, advanced object inference, and PyCore modules pass: 312 passed.
  • Full suite: 2177 passed, 11 skipped, 5 xfailed, 1 failed, 1 error. The exact unmodified base gives 2174 passed with the same skips, xfails, failure, and error. The forkserver test cannot create an AF_UNIX socket in this environment; the compiled-module fixture expects _sqlite3.__file__, which this statically linked runtime does not provide.
  • All configured pre-commit hooks pass on the changed files. The complete Sphinx HTML documentation build succeeds.

This patch and its validation were prepared with ChatGPT (GPT-6 Astra Pro).

Checklist (delete if not relevant):

  • I have added tests that prove my fix is effective or that my feature works
  • I have updated CHANGELOG.md
  • I have made corresponding changes to user documentation for new features
  • I have made corresponding changes to library documentation for API changes

Preserve resource notifications and default automatic_soa behavior.

Related to python-rope#925.
Cover skipping analysis, resuming default analysis, and preserving automatic_soa preferences.
Use an editor-style filesystem overlay and verify parsed modules refresh without writing the buffer to disk.
Explain notification-only updates and how to resume analysis after several edits.
Document the additive public API for editor buffer notifications.
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.45%. Comparing base (ff8a306) to head (273fd94).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #970      +/-   ##
==========================================
+ Coverage   95.44%   95.45%   +0.01%     
==========================================
  Files         134      134              
  Lines       26910    26960      +50     
==========================================
+ Hits        25685    25736      +51     
+ Misses       1225     1224       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant