Skip to content

Commit

Permalink
fix(extract-method): Add support for augmented assignments to subscri…
Browse files Browse the repository at this point in the history
…ptable inside try..except block

fixes python-rope#459
  • Loading branch information
dryobates committed Mar 15, 2022
1 parent cddc9e2 commit fad37df
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rope/refactor/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,12 @@ def _Assign(self, node):

def _AugAssign(self, node):
ast.walk(node.value, self)
self._read_variable(node.target.id, node.target.lineno)
self._written_variable(node.target.id, node.target.lineno)
if isinstance(node.target, ast.Subscript):
target_id = node.target.value.id
else:
target_id = node.target.id
self._read_variable(target_id, node.target.lineno)
self._written_variable(target_id, node.target.lineno)

def _ClassDef(self, node):
self._written_variable(node.name, node.lineno)
Expand Down

0 comments on commit fad37df

Please sign in to comment.