Implement nonlocal variables scoping rule for rename refactor
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- developer-experience, tooling
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 2.2k
- Forks
- 197
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-rope/rope
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
python-rope/rope#927 ·
Los mantenedores suelen responder en 2 días
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionPosiblemente ocupada @aliassar la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-rope/rope#926 ·
Los mantenedores suelen responder en 2 días
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetPosiblemente ocupada @sean0407 la tomó hace 13 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
python-rope/rope#913 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
python-rope/rope#925 ·
Los mantenedores suelen responder en 2 días
-
Extract method/variable and introduce parameter don't check whether the new name is already in usePosiblemente ocupada @aliassar la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
python-rope/rope#924 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de python-rope/rope
Issues similares
-
area/test type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Clodmony/starship-coop#70 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
punitarani/fli#270 ·
-
🐛 Bug 🔔 Pending processing
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
jumpserver/jumpserver#17980 ·
Los mantenedores suelen responder en 1 día
-
community enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
Claiming namespace `prodmetrics`Abiertonamespace
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
EclipseFdn/open-vsx.org#15341 ·
Los mantenedores suelen responder en 1 día