mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
inline refactorings support tuples now, #103
This commit is contained in:
@@ -171,12 +171,17 @@ def inline(script):
|
|||||||
|
|
||||||
line = new_lines[index]
|
line = new_lines[index]
|
||||||
replace_str = line[ass.start_pos[1]:ass.end_pos[1] + 1]
|
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 it's the only assignment, remove the statement
|
||||||
if len(stmt.set_vars) == 1:
|
if len(stmt.set_vars) == 1:
|
||||||
line = line[:stmt.start_pos[1]] + line[stmt.end_pos[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
|
# remove the empty line
|
||||||
new_lines = dct[script.source_path][2]
|
new_lines = dct[script.source_path][2]
|
||||||
if line.strip():
|
if line.strip():
|
||||||
|
|||||||
@@ -6,3 +6,13 @@ def test():
|
|||||||
# +++
|
# +++
|
||||||
def test():
|
def test():
|
||||||
return test(100, (30 + b, c) + 1)
|
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))
|
||||||
|
|||||||
Reference in New Issue
Block a user