mirror of
https://github.com/davidhalter/jedi.git
synced 2026-10-21 18:27:05 +08:00
Fix extract_function when the extracted code defines no variable
If the extracted lines define no name, the new function ended with a bare "return " and the call site became " = func(v1)". Both are invalid Python. Only add the final return line and the assignment when there is at least one variable to return. Otherwise call the function as a statement.
This commit is contained in:
3 files changed
+22
-2
No files matched your search
@@ -314,6 +314,22 @@ def x(v1):
|
||||
#bar
|
||||
return x
|
||||
x
|
||||
# -------------------------------------------------- with-range-func-no-output
|
||||
def x(v1):
|
||||
#? 2 text {'new_name': 'func', 'until_line': 4}
|
||||
print(v1)
|
||||
print(v1 + 1)
|
||||
return v1
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
def func(v1):
|
||||
print(v1)
|
||||
print(v1 + 1)
|
||||
|
||||
|
||||
def x(v1):
|
||||
#? 2 text {'new_name': 'func', 'until_line': 4}
|
||||
func(v1)
|
||||
return v1
|
||||
# -------------------------------------------------- in-class-range-1
|
||||
class X1:
|
||||
#? 9 text {'new_name': 'f', 'until_line': 4}
|
||||
|
||||
Reference in new issue
Block a user