forked from VimPlug/jedi
Cache getting resolved param names
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from jedi._compatibility import Parameter
|
from jedi._compatibility import Parameter
|
||||||
|
from jedi.cache import memoize_method
|
||||||
|
|
||||||
|
|
||||||
class _SignatureMixin(object):
|
class _SignatureMixin(object):
|
||||||
@@ -80,6 +81,7 @@ class TreeSignature(AbstractSignature):
|
|||||||
return ''
|
return ''
|
||||||
return a.get_code(include_prefix=False)
|
return a.get_code(include_prefix=False)
|
||||||
|
|
||||||
|
@memoize_method
|
||||||
def get_param_names(self, resolve_stars=False):
|
def get_param_names(self, resolve_stars=False):
|
||||||
params = super(TreeSignature, self).get_param_names()
|
params = super(TreeSignature, self).get_param_names()
|
||||||
if resolve_stars:
|
if resolve_stars:
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ class PartialSignature(SignatureWrapper):
|
|||||||
self._skipped_arg_count = skipped_arg_count
|
self._skipped_arg_count = skipped_arg_count
|
||||||
self._skipped_arg_set = skipped_arg_set
|
self._skipped_arg_set = skipped_arg_set
|
||||||
|
|
||||||
def get_param_names(self):
|
def get_param_names(self, resolve_stars=False):
|
||||||
names = self._wrapped_signature.get_param_names()[self._skipped_arg_count:]
|
names = self._wrapped_signature.get_param_names()[self._skipped_arg_count:]
|
||||||
return [n for n in names if n.string_name not in self._skipped_arg_set]
|
return [n for n in names if n.string_name not in self._skipped_arg_set]
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ class DataclassSignature(AbstractSignature):
|
|||||||
super(DataclassSignature, self).__init__(context)
|
super(DataclassSignature, self).__init__(context)
|
||||||
self._param_names = param_names
|
self._param_names = param_names
|
||||||
|
|
||||||
def get_param_names(self):
|
def get_param_names(self, resolve_stars=False):
|
||||||
return self._param_names
|
return self._param_names
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ def test_nested_signatures(Script, environment, combination, expected, skip_pre_
|
|||||||
code += 'z = ' + combination + '\nz('
|
code += 'z = ' + combination + '\nz('
|
||||||
sig, = Script(code).call_signatures()
|
sig, = Script(code).call_signatures()
|
||||||
computed = sig._signature.to_string()
|
computed = sig._signature.to_string()
|
||||||
if not re.match('\w+\(', expected):
|
if not re.match(r'\w+\(', expected):
|
||||||
expected = '<lambda>(' + expected + ')'
|
expected = '<lambda>(' + expected + ')'
|
||||||
assert expected == computed
|
assert expected == computed
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user