Skip to content

Use full lines for Python relative import moves - #587

Closed
tristanmanchester wants to merge 1 commit into
peteromallet:mainfrom
tristanmanchester:fix/python-move-relative-import-prefix
Closed

Use full lines for Python relative import moves#587
tristanmanchester wants to merge 1 commit into
peteromallet:mainfrom
tristanmanchester:fix/python-move-relative-import-prefix

Conversation

@tristanmanchester

@tristanmanchester tristanmanchester commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace full relative import lines instead of generic from .. prefixes when updating Python move imports
  • cover both importer rewrites and self-rewrites in the Python move helper
  • add a regression proving from .. import X no longer corrupts sibling imports like from ..utils import Y during apply

Testing

  • uv run --with pytest python -m pytest desloppify/languages/python/tests/test_py_move.py

@peteromallet

Copy link
Copy Markdown
Owner

Thanks @tristanmanchester. I accepted and applied this change.

Decision: implemented. The review confirmed this was a real Python move-command corruption bug: replacing a broad relative prefix such as from .. could accidentally rewrite sibling imports like from ..utils import helper. I applied the narrow fix so relative from-import moves replace the matched full import line/module portion, added the regression from the PR, and committed it as 1860dd6.

Validation passed:

  • PYENV_VERSION=3.11.11 python -m pytest desloppify/languages/python/tests/test_py_move.py -q
  • PYENV_VERSION=3.11.11 python -m pytest desloppify/tests/ -q

Closing this PR because the fix has been carried into the local integration branch.

@peteromallet

Copy link
Copy Markdown
Owner

Closing after applying the accepted fix locally in commit 1860dd6. Thanks again for the contribution.

pull Bot pushed a commit to Stars1233/desloppify that referenced this pull request May 13, 2026
Cherry-picked from PR peteromallet#587 by @tristanmanchester

Co-Authored-By: Tristan Manchester <U_kgDOBnQUJA+tristanmanchester@users.noreply.github.com>

Co-Authored-By: OpenAI Codex <noreply@openai.com>
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.

2 participants