forked from VimPlug/jedi
fix the named param issue in the autocompletion
This commit is contained in:
@@ -163,6 +163,7 @@ class Script(object):
|
|||||||
# 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.
|
||||||
|
if p._definition.stars == 0: # no *args/**kwargs
|
||||||
completions.append((p._definition.get_name(), p))
|
completions.append((p._definition.get_name(), p))
|
||||||
|
|
||||||
if not path and not isinstance(user_stmt, pr.Import):
|
if not path and not isinstance(user_stmt, pr.Import):
|
||||||
|
|||||||
@@ -567,7 +567,9 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
|||||||
if isinstance(d, pr.Param):
|
if isinstance(d, pr.Param):
|
||||||
try:
|
try:
|
||||||
return unicode(d.expression_list()[0].name)
|
return unicode(d.expression_list()[0].name)
|
||||||
except IndexError:
|
except (IndexError, AttributeError):
|
||||||
|
# IndexError for syntax error params
|
||||||
|
# AttributeError for *args/**kwargs
|
||||||
pass
|
pass
|
||||||
return None
|
return None
|
||||||
elif isinstance(d, iterable.Generator):
|
elif isinstance(d, iterable.Generator):
|
||||||
|
|||||||
@@ -1181,6 +1181,13 @@ class Param(Statement):
|
|||||||
debug.warning("Multiple param names (%s).", n)
|
debug.warning("Multiple param names (%s).", n)
|
||||||
return n[0]
|
return n[0]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def stars(self):
|
||||||
|
exp = self.expression_list()
|
||||||
|
if exp and isinstance(exp[0], Operator):
|
||||||
|
return exp[0].string.count('*')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
class StatementElement(Simple):
|
class StatementElement(Simple):
|
||||||
__slots__ = ('parent', 'next', 'execution')
|
__slots__ = ('parent', 'next', 'execution')
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
""" named params:
|
"""
|
||||||
|
Named Params:
|
||||||
>>> def a(abc): pass
|
>>> def a(abc): pass
|
||||||
...
|
...
|
||||||
>>> a(abc=3) # <- this stuff
|
>>> a(abc=3) # <- this stuff (abc)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def a(abc):
|
def a(abc):
|
||||||
@@ -18,4 +19,4 @@ def a(*some_args, **some_kwargs):
|
|||||||
a(some_args)
|
a(some_args)
|
||||||
|
|
||||||
#? 13 []
|
#? 13 []
|
||||||
a(some_kwargs
|
a(some_kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user