1
0
forked from VimPlug/jedi

Fix an issue of params completion signatures.

This commit is contained in:
Dave Halter
2017-01-04 22:09:03 +01:00
parent 55ec47f15f
commit e96fd32588
2 changed files with 14 additions and 7 deletions

View File

@@ -6,7 +6,6 @@ from jedi.api import classes
from jedi.api import helpers from jedi.api import helpers
from jedi.evaluate import imports from jedi.evaluate import imports
from jedi.api import keywords from jedi.api import keywords
from jedi.evaluate import compiled
from jedi.evaluate.helpers import evaluate_call_of_leaf from jedi.evaluate.helpers import evaluate_call_of_leaf
from jedi.evaluate.filters import get_global_filters from jedi.evaluate.filters import get_global_filters
@@ -14,15 +13,15 @@ from jedi.evaluate.filters import get_global_filters
def get_call_signature_param_names(call_signatures): def get_call_signature_param_names(call_signatures):
# add named params # add named params
for call_sig in call_signatures: for call_sig in call_signatures:
# Allow protected access, because it's a public API.
module = call_sig._name.get_root_context()
# Compiled modules typically don't allow keyword arguments.
if not isinstance(module, compiled.CompiledObject):
for p in call_sig.params: for p in call_sig.params:
# Allow protected access, because it's a public API.
tree_name = p._name.tree_name
# Compiled modules typically don't allow keyword arguments.
if tree_name is not None:
# Allow access on _definition here, because it's a # Allow access on _definition here, because it's a
# public API and we don't want to make the internal # public API and we don't want to make the internal
# Name object public. # Name object public.
tree_param = tree.search_ancestor(p._name.tree_name, 'param') tree_param = tree.search_ancestor(tree_name, 'param')
if tree_param.stars == 0: # no *args/**kwargs if tree_param.stars == 0: # no *args/**kwargs
yield p._name yield p._name

View File

@@ -7,3 +7,11 @@ def test_in_whitespace():
def x(): def x():
pass''') pass''')
assert len(Script(code, column=2).completions()) > 20 assert len(Script(code, column=2).completions()) > 20
def test_empty_init():
"""This was actually an issue."""
code = dedent('''\
class X(object): pass
X(''')
assert Script(code).completions()