diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 7531598a..a4bf8784 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -759,10 +759,11 @@ class Script(object): global_var = 3 def bar(foo): - return foo + 1 + global_var + return int(foo + 1 + global_var) - def x(foo): - x = int(bar(foo)) + def x(): + foo = 3.1 + x = bar(foo) :param new_name: The expression under the cursor will be replaced with a function with this name. diff --git a/test/refactor/extract_function.py b/test/refactor/extract_function.py index 36d09474..da2fd259 100644 --- a/test/refactor/extract_function.py +++ b/test/refactor/extract_function.py @@ -1,3 +1,19 @@ +# -------------------------------------------------- in-module-0 +global_var = 3 +def x(): + foo = 3.1 + #? 11 text {'new_name': 'bar'} + x = int(foo + 1 + global_var) +# ++++++++++++++++++++++++++++++++++++++++++++++++++ +global_var = 3 +def bar(foo): + return int(foo + 1 + global_var) + + +def x(): + foo = 3.1 + #? 11 text {'new_name': 'bar'} + x = bar(foo) # -------------------------------------------------- in-module-1 glob = 3 #? 11 text {'new_name': 'a'}