Repository navigation
Fix namespace package directory renames - #902
Open
yangfan-yf-yf wants to merge 1 commit into
Open
yangfan-yf-yf wants to merge 1 commit into
yangfan-yf-yf wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #902 +/- ##
==========================================
+ Coverage 95.34% 95.37% +0.03%
==========================================
Files 134 135 +1
Lines 26762 26896 +134
==========================================
+ Hits 25516 25652 +136
+ Misses 1246 1244 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I fixed directory renames for namespace packages without an
__init__.py. Renaming a package such asvaluespkg, imported withimport valuespkg.foreign, currently raisesRecursionErrorbefore producing changes: the local-name check asks the package for its scope, and the package delegates back to itself.I now check local scope only for assigned names, which are the only names that can satisfy the existing local-variable predicate. A default project-wide namespace package rename updates imports and moves the directory together. With an explicit resource list, the directory moves only when all its project Python files are selected and there is at least one such file. Importer-only selections continue to update the selected files without moving the package; ordinary package and module move rules are preserved.
The regression tests exercise actual directory moves, saved module values, nested namespace packages with relative imports, import aliases, empty namespace packages, explicit resource limits, and ordinary package controls. Successful cases run before and after the rename and preserve an unrelated resource. This change is limited to Rename and does not introduce a general namespace package scope implementation.
Validation: the original six-case baseline fails in five namespace cases with
RecursionErrorand passes the ordinary-package control on Python 3.12 and 3.14. The fix passes all ten regression tests and all 263 related Rename, Move, scope, and object-inference tests on both versions. Black, isort, the configured checks, andgit diff --checkpass. The complete suite passes on Python 3.12 (2159 passed, 12 skipped, 5 xfailed) and 3.14 (2163 passed, 8 skipped, 5 xfailed), with 2176 collected on each version.Checklist