Implement nonlocal variables scoping rule for rename refactor
Maintainer antworten meist innerhalb von 2 Tagen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- developer-experience, tooling
Rechercherichtung
Start by reading the rename refactor implementation and its tests for variable scope handling; the issue does not name specific files or tests. Trace how definitions and references are resolved across nested functions, then add coverage for the nonlocal cases in the example. Done means renaming the variable defined in outer updates its nested nonlocal references and read, while leaving the global name and inner4 variable unchanged.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Is your feature request related to a problem? Please describe.
Rename refactor does not understand nonlocal variables scoping rules at all.
Describe the solution you'd like
Given this code:
var_x = "global" # shadowed variable in global scope should not be renamed
def outer():
def inner1():
nonlocal var_x # when renaming this
var_x = 1
def inner2():
nonlocal var_x # declared nonlocal from a different inner function, should be renamed
var_x = 2
def inner3():
print(var_x) # undeclared read-only nonlocal, should be renamed
def inner4():
var_x = 4 # this creates separate scope, should not be renamed
var_x = None # this is the definition location of the var_x, should be renamed
return var_x
Currently rename refactor only rename variables in one function at a time.
-
Expected code after refactoring: All instances of
var_xinsider outer, except inner4 should be renamed. -
Describe the error or unexpected result that you are getting: currently, each function gets treated as their own scope and inner functions variables don't get renamed and vice versa
Editor information (please complete the following information):
- Rope version: 1.15.2
- Vorherrschende Sprache
- Python
- Sterne
- 2.2k
- Forks
- 197
- Ø Merge
- 1 T. 20 Std.
- Gemergte PRs (30 T.)
- 7
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-rope/rope
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
python-rope/rope#927 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionEvtl. vergeben @aliassar hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
python-rope/rope#926 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetEvtl. vergeben @sean0407 hat das vor 13 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
python-rope/rope#913 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
python-rope/rope#925 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Extract method/variable and introduce parameter don't check whether the new name is already in useEvtl. vergeben @aliassar hat das vor 1 Tag übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
python-rope/rope#924 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in python-rope/rope
Ähnliche Issues
-
area/test type/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Clodmony/starship-coop#70 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
punitarani/fli#270 ·
-
🐛 Bug 🔔 Pending processing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
jumpserver/jumpserver#17980 ·
Maintainer antworten meist innerhalb von 1 Tag
-
community enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag
-
namespace
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
EclipseFdn/open-vsx.org#15341 ·
Maintainer antworten meist innerhalb von 1 Tag