Skip to content

Fix field renames after external class data writes - #901

Open
yangfan-yf-yf wants to merge 2 commits into
python-rope:masterfrom
yangfan-yf-yf:fix/external-class-data-values
Open

yangfan-yf-yf wants to merge 2 commits into
python-rope:masterfrom
yangfan-yf-yf:fix/external-class-data-values

Conversation

@yangfan-yf-yf

@yangfan-yf-yf yangfan-yf-yf commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

After Box.slot = Value(), renaming Value.field can leave Box.slot.field unchanged and break execution. I track a single unconditional module-level data assignment when both classes are defined in the same module with unique bindings, including replacement of an existing attribute. I preserve the original import source identity separately from the replacement attribute value.

I reject affected renames before producing changes when earlier reads, rebinding, repeated or conditional writes, inheritance, or lookup hooks make the value uncertain. Callable and descriptor assignments, general dynamic/factory inference, and arbitrary containers remain outside this support.

I added regression controls for imported factories, module aliases and cycles, nested classes, namespace modules, Unicode import offsets, and local pattern/exception/unpacking rebinding. A potentially affected field rename must preserve execution or refuse changes atomically; an unrelated global rename and an ordinary referenced field rename must still succeed.

I validated the current change locally:

  • The complete Python 3.12 suite: 2242 passed, 12 skipped, 5 xfailed (2259 collected).
  • All 93 regression cases passed on both Python 3.12 and 3.14.
  • The 303 focused compatibility cases with Preserve annotation, lambda and comprehension source bindings #900: 288 passed/15 skipped on 3.12 and 286 passed/17 skipped on 3.14. This is the selected integration scope.
  • Black, isort and the configured checks passed.

Checklist

  • 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

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.02220% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.39%. Comparing base (22f5e50) to head (a6da74e).

Files with missing lines Patch % Lines
rope/base/externaldata.py 92.14% 40 Missing ⚠️
ropetest/external_data_attributes_test.py 99.46% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #901      +/-   ##
==========================================
+ Coverage   95.34%   95.39%   +0.04%     
==========================================
  Files         134      136       +2     
  Lines       26762    27843    +1081     
==========================================
+ Hits        25516    26560    +1044     
- Misses       1246     1283      +37     

☔ 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