diff --git a/jedi/refactoring.py b/jedi/refactoring.py index 64414f5b..677f1051 100644 --- a/jedi/refactoring.py +++ b/jedi/refactoring.py @@ -171,12 +171,17 @@ def inline(script): line = new_lines[index] replace_str = line[ass.start_pos[1]:ass.end_pos[1] + 1] + replace_str = replace_str.strip() + # tuples need parentheses + if len(ass.values) > 1: + replace_str = '(%s)' % replace_str # if it's the only assignment, remove the statement if len(stmt.set_vars) == 1: line = line[:stmt.start_pos[1]] + line[stmt.end_pos[1]:] - dct = _rename(inlines, replace_str.strip()) + + dct = _rename(inlines, replace_str) # remove the empty line new_lines = dct[script.source_path][2] if line.strip(): diff --git a/test/refactor/inline.py b/test/refactor/inline.py index d1d9a206..c373be25 100644 --- a/test/refactor/inline.py +++ b/test/refactor/inline.py @@ -6,3 +6,13 @@ def test(): # +++ def test(): return test(100, (30 + b, c) + 1) + + +# --- simple +if 1: + #? 4 + a = 1, 2 + return test(100, a) +# +++ +if 1: + return test(100, (1, 2))