From 98ee2d9675ce8f1f01007616f6a9b076cf486cbd Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 21 Feb 2013 20:23:19 +0430 Subject: [PATCH] fixed refactoring: inline --- jedi/refactoring.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jedi/refactoring.py b/jedi/refactoring.py index 0bf191ec..01bc362a 100644 --- a/jedi/refactoring.py +++ b/jedi/refactoring.py @@ -11,7 +11,6 @@ following functions (sometimes bug-prone): - rename - extract variable - inline variable - """ from __future__ import with_statement @@ -19,6 +18,7 @@ from __future__ import with_statement import modules import difflib import helpers +import parsing_representation as pr class Refactoring(object): @@ -183,11 +183,13 @@ def inline(script): index = stmt.start_pos[0] - 1 line = new_lines[index] - replace_str = line[stmt.start_pos[1]:stmt.end_pos[1] + 1] + replace_str = line[commands[0].start_pos[1]:stmt.end_pos[1] + 1] replace_str = replace_str.strip() # tuples need parentheses - if len(commands) > 1: - replace_str = '(%s)' % replace_str + if commands and isinstance(commands[0], pr.Array): + arr = commands[0] + if replace_str[0] not in ['(', '[', '{'] and len(arr) > 1: + replace_str = '(%s)' % replace_str # if it's the only assignment, remove the statement if len(stmt.set_vars) == 1: