Skip to content

Preserve relative imports and aliases when moving globals - #960

Open
marlon-costa-dc wants to merge 1 commit into
python-rope:masterfrom
marlon-costa-dc:fix/upstream-move-global-aliases
Open

marlon-costa-dc wants to merge 1 commit into
python-rope:masterfrom
marlon-costa-dc:fix/upstream-move-global-aliases

Conversation

@marlon-costa-dc

Copy link
Copy Markdown
Contributor

Moving a global can leave consumers importing it from the old module. For example, moving Thing out of pkg.origin.__init__ leaves from .origin import Thing as Alias pointing at the old package, and importing the rewritten consumer raises ImportError.

Resolve relative imports from the consumer’s folder and move the matching alias to the destination. Other names in the same import stay in place. Consumers that use only the alias are also updated.

Verified with the real create_move API and a subprocess that imports the rewritten consumer: it raises ImportError on master and both references resolve to the destination class after this change. The full Python 3.14 suite passed (2,184 passed, 7 skipped, 5 xfailed).

@codecov

codecov Bot commented Nov 14, 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 (fc0512e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #960   +/-   ##
=======================================
  Coverage   95.44%   95.45%           
=======================================
  Files         134      134           
  Lines       26910    26968   +58     
=======================================
+ Hits        25685    25743   +58     
  Misses       1225     1225           

☔ 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