1
0
forked from VimPlug/jedi
Files
jedi-fork/jedi/evaluate/signature.py
2018-11-18 23:53:56 +01:00

51 lines
1.3 KiB
Python

from abc import abstractproperty
class AbstractSignature(object):
def __init__(self, context, is_bound=False):
self.context = context
self.is_bound = is_bound
@abstractproperty
def name(self):
return self.context.name
def annotation(self):
return None
def to_string(self):
raise NotImplementedError
def bind(self, context):
raise NotImplementedError
def get_param_names(self):
param_names = self._function_context.get_param_names()
if self.is_bound:
return param_names[1:]
return param_names
class TreeSignature(AbstractSignature):
def __init__(self, context, function_context=None, is_bound=False):
super(TreeSignature, self).__init__(context, is_bound)
self._function_context = function_context or context
def bind(self, context):
return TreeSignature(context, self._function_context, is_bound=True)
def annotation(self):
return self._function_context.tree_node.annotation
def to_string(self, normalize=False):
return self._function_context.tree_node
class BuiltinSignature(AbstractSignature):
@property
def _function_context(self):
return self.context
def bind(self, context):
raise NotImplementedError('pls implement, need test case, %s' % context)