Implement nonlocal variables scoping rule for rename refactor
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 2.2k
- フォーク
- 197
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-rope/rope のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
python-rope/rope#927 ·
メンテナーはふだん 2 日以内に返信
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only region対応中かも @aliassar が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
python-rope/rope#926 ·
メンテナーはふだん 2 日以内に返信
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offset対応中かも @sean0407 が 13 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
python-rope/rope#913 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
python-rope/rope#925 ·
メンテナーはふだん 2 日以内に返信
-
Extract method/variable and introduce parameter don't check whether the new name is already in use対応中かも @aliassar が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
python-rope/rope#924 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
python-rope/rope の issue をすべて見る
似ている issue
-
area/test type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Clodmony/starship-coop#70 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
punitarani/fli#270 ·
-
🐛 Bug 🔔 Pending processing
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
jumpserver/jumpserver#17980 ·
メンテナーはふだん 1 日以内に返信
-
community enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
namespace
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
EclipseFdn/open-vsx.org#15341 ·
メンテナーはふだん 1 日以内に返信