mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix __call__ param completion. Fixes #613.
This commit is contained in:
@@ -345,12 +345,20 @@ class BaseDefinition(object):
|
|||||||
params = followed.params
|
params = followed.params
|
||||||
elif followed.isinstance(er.compiled.CompiledObject):
|
elif followed.isinstance(er.compiled.CompiledObject):
|
||||||
params = followed.params
|
params = followed.params
|
||||||
else:
|
elif isinstance(followed, er.Class):
|
||||||
try:
|
try:
|
||||||
sub = followed.get_subscope_by_name('__init__')
|
sub = followed.get_subscope_by_name('__init__')
|
||||||
params = sub.params[1:] # ignore self
|
params = sub.params[1:] # ignore self
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return []
|
return []
|
||||||
|
elif isinstance(followed, er.Instance):
|
||||||
|
try:
|
||||||
|
sub = followed.get_subscope_by_name('__call__')
|
||||||
|
params = sub.params[1:] # ignore self
|
||||||
|
except KeyError:
|
||||||
|
return []
|
||||||
|
else:
|
||||||
|
return []
|
||||||
return [_Param(self._evaluator, p.name) for p in params]
|
return [_Param(self._evaluator, p.name) for p in params]
|
||||||
|
|
||||||
def parent(self):
|
def parent(self):
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ Helpers for the API
|
|||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from textwrap import dedent
|
|
||||||
|
|
||||||
from jedi._compatibility import u
|
from jedi._compatibility import u
|
||||||
from jedi.evaluate.helpers import call_of_leaf
|
from jedi.evaluate.helpers import call_of_leaf
|
||||||
from jedi import parser
|
from jedi import parser
|
||||||
from jedi.parser import tokenize, token
|
from jedi.parser import tokenize
|
||||||
from jedi.cache import time_cache
|
from jedi.cache import time_cache
|
||||||
from jedi import common
|
from jedi import common
|
||||||
|
|
||||||
@@ -279,7 +278,7 @@ def get_call_signature_details(module, position):
|
|||||||
# makes it feel strange to have a call signature.
|
# makes it feel strange to have a call signature.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for n in node.children:
|
for n in node.children[::-1]:
|
||||||
if n.start_pos < position and n.type == 'error_node':
|
if n.start_pos < position and n.type == 'error_node':
|
||||||
result = _get_call_signature_details_from_error_node(n, position)
|
result = _get_call_signature_details_from_error_node(n, position)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
|
|||||||
@@ -33,3 +33,16 @@ multiple(foo, bar
|
|||||||
my_lambda = lambda lambda_param: lambda_param + 1
|
my_lambda = lambda lambda_param: lambda_param + 1
|
||||||
#? 22 ['lambda_param']
|
#? 22 ['lambda_param']
|
||||||
my_lambda(lambda_param)
|
my_lambda(lambda_param)
|
||||||
|
|
||||||
|
# __call__
|
||||||
|
class Test(object):
|
||||||
|
def __init__(self, hello_other):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __call__(self, hello):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#? 12 ['hello']
|
||||||
|
Test()(hello=)
|
||||||
|
#? 11 []
|
||||||
|
Test()(self=)
|
||||||
|
|||||||
Reference in New Issue
Block a user