mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Raise a deprecation warning on Definition.params
This commit is contained in:
@@ -362,14 +362,18 @@ class BaseDefinition(object):
|
|||||||
Raises an ``AttributeError`` if the definition is not callable.
|
Raises an ``AttributeError`` if the definition is not callable.
|
||||||
Otherwise returns a list of `Definition` that represents the params.
|
Otherwise returns a list of `Definition` that represents the params.
|
||||||
"""
|
"""
|
||||||
|
warnings.warn(
|
||||||
|
"Deprecated since version 0.16.0. Use get_signatures()[...].params",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2
|
||||||
|
)
|
||||||
# Only return the first one. There might be multiple one, especially
|
# Only return the first one. There might be multiple one, especially
|
||||||
# with overloading.
|
# with overloading.
|
||||||
for value in self._name.infer():
|
for signature in self._get_signatures():
|
||||||
for signature in value.get_signatures():
|
return [
|
||||||
return [
|
Definition(self._inference_state, n)
|
||||||
Definition(self._inference_state, n)
|
for n in signature.get_param_names(resolve_stars=True)
|
||||||
for n in signature.get_param_names(resolve_stars=True)
|
]
|
||||||
]
|
|
||||||
|
|
||||||
if self.type == 'function' or self.type == 'class':
|
if self.type == 'function' or self.type == 'class':
|
||||||
# Fallback, if no signatures were defined (which is probably by
|
# Fallback, if no signatures were defined (which is probably by
|
||||||
@@ -435,6 +439,9 @@ class BaseDefinition(object):
|
|||||||
start_index = max(index - before, 0)
|
start_index = max(index - before, 0)
|
||||||
return ''.join(lines[start_index:index + after + 1])
|
return ''.join(lines[start_index:index + after + 1])
|
||||||
|
|
||||||
|
def _get_signatures(self):
|
||||||
|
return self._name.infer().get_signatures()
|
||||||
|
|
||||||
def get_signatures(self):
|
def get_signatures(self):
|
||||||
return [
|
return [
|
||||||
BaseSignature(self._inference_state, s)
|
BaseSignature(self._inference_state, s)
|
||||||
|
|||||||
Reference in New Issue
Block a user