From 32687474dba6fa77bc57b433ea6d6035f232e1d5 Mon Sep 17 00:00:00 2001 From: yuan_xy Date: Fri, 29 May 2020 08:17:39 +0800 Subject: [PATCH] add test case to fix code example in doc --- jedi/api/__init__.py | 7 ++++--- test/refactor/extract_function.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) 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'}