mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-05 18:17:40 +08:00
Make sure that equals will only be added to keyword arguments and not just randomly
This commit is contained in:
@@ -8,7 +8,7 @@ Named Params:
|
||||
def a(abc):
|
||||
pass
|
||||
|
||||
#? 5 ['abc']
|
||||
#? 5 ['abc=']
|
||||
a(abc)
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@ a(some_kwargs)
|
||||
def multiple(foo, bar):
|
||||
pass
|
||||
|
||||
#? 17 ['bar']
|
||||
#? 17 ['bar=']
|
||||
multiple(foo, bar)
|
||||
|
||||
#? ['bar']
|
||||
#? ['bar=']
|
||||
multiple(foo, bar
|
||||
|
||||
my_lambda = lambda lambda_param: lambda_param + 1
|
||||
#? 22 ['lambda_param']
|
||||
#? 22 ['lambda_param=']
|
||||
my_lambda(lambda_param)
|
||||
|
||||
# __call__ / __init__
|
||||
@@ -45,15 +45,15 @@ class Test(object):
|
||||
def test(self, blub):
|
||||
pass
|
||||
|
||||
#? 10 ['hello_other']
|
||||
#? 10 ['hello_other=']
|
||||
Test(hello=)
|
||||
#? 12 ['hello']
|
||||
#? 12 ['hello=']
|
||||
Test()(hello=)
|
||||
#? 11 []
|
||||
Test()(self=)
|
||||
#? 16 []
|
||||
Test().test(self=)
|
||||
#? 16 ['blub']
|
||||
#? 16 ['blub=']
|
||||
Test().test(blub=)
|
||||
|
||||
# builtins
|
||||
@@ -65,7 +65,7 @@ any(iterable=)
|
||||
def foo(xyz):
|
||||
pass
|
||||
|
||||
#? 7 ['xyz']
|
||||
#? 7 ['xyz=']
|
||||
foo(xyz)
|
||||
# No completion should be possible if it's not a simple name
|
||||
#? 17 []
|
||||
@@ -81,11 +81,11 @@ x = " "; foo(xyz[xyz)
|
||||
#? 20 []
|
||||
x = " "; foo(xyz[(xyz)
|
||||
|
||||
#? 8 ['xyz']
|
||||
#? 8 ['xyz=']
|
||||
@foo(xyz)
|
||||
def x(): pass
|
||||
|
||||
@str
|
||||
#? 8 ['xyz']
|
||||
#? 8 ['xyz=']
|
||||
@foo(xyz)
|
||||
def x(): pass
|
||||
|
||||
@@ -149,6 +149,18 @@ def test_with_stmt_error_recovery(Script):
|
||||
assert Script('with open('') as foo: foo.\na').complete(line=1)
|
||||
|
||||
|
||||
def test_function_param_usage(Script):
|
||||
c, = Script('def func(foo_value):\n str(foo_valu').complete()
|
||||
assert c.complete == 'e'
|
||||
assert c.name == 'foo_value'
|
||||
|
||||
c1, c2 = Script('def func(foo_value):\n func(foo_valu').complete()
|
||||
assert c1.complete == 'e'
|
||||
assert c1.name == 'foo_value'
|
||||
assert c2.complete == 'e='
|
||||
assert c2.name == 'foo_value='
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'code, has_keywords', (
|
||||
('', True),
|
||||
|
||||
@@ -311,8 +311,8 @@ def test_param_completion():
|
||||
|
||||
lambd = lambda xyz: 3
|
||||
|
||||
_assert_interpreter_complete('foo(bar', locals(), ['bar'])
|
||||
assert bool(jedi.Interpreter('lambd(xyz', [locals()]).complete()) == is_py3
|
||||
_assert_interpreter_complete('foo(bar', locals(), ['bar='])
|
||||
_assert_interpreter_complete('lambd(xyz', locals(), ['xyz='])
|
||||
|
||||
|
||||
def test_endless_yield():
|
||||
@@ -357,7 +357,7 @@ def test_keyword_argument():
|
||||
pass
|
||||
|
||||
c, = jedi.Interpreter("f(some_keyw", [{'f': f}]).complete()
|
||||
assert c.name == 'some_keyword_argument'
|
||||
assert c.name == 'some_keyword_argument='
|
||||
assert c.complete == 'ord_argument='
|
||||
|
||||
# This needs inspect.signature to work.
|
||||
@@ -365,7 +365,7 @@ def test_keyword_argument():
|
||||
# Make it impossible for jedi to find the source of the function.
|
||||
f.__name__ = 'xSOMETHING'
|
||||
c, = jedi.Interpreter("x(some_keyw", [{'x': f}]).complete()
|
||||
assert c.name == 'some_keyword_argument'
|
||||
assert c.name == 'some_keyword_argument='
|
||||
|
||||
|
||||
def test_more_complex_instances():
|
||||
|
||||
Reference in New Issue
Block a user