From b748003b5405cf435a83b43f20bb00b3fb19b808 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 7 Jan 2013 20:26:17 +0100 Subject: [PATCH] inline refactorings support tuples now, #103 --- jedi/refactoring.py | 7 ++++++- test/refactor/inline.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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))