1
0
forked from VimPlug/jedi

Start implementing overload function

This commit is contained in:
Dave Halter
2018-08-26 03:37:26 +02:00
parent 4daa73d487
commit ac7ce7c481
8 changed files with 27 additions and 15 deletions

View File

@@ -130,7 +130,7 @@ class AbstractInstanceContext(Context):
def py__getitem__(self, index_context_set, contextualized_node):
names = self.get_function_slot_names(u'__getitem__')
if not names:
debug.warning('No __getitem__, cannot access the array.')
debug.warning('Found no __getitem__ on %s', self)
return NO_CONTEXTS
args = ValuesArguments([index_context_set])

View File

@@ -17,7 +17,7 @@ and others. Here's a list:
====================================== ========================================
**Method** **Description**
-------------------------------------- ----------------------------------------
py__call__(params: Array) On callable objects, returns types.
py__call__(arguments: Array) On callable objects, returns types.
py__bool__() Returns True/False/None; None means that
there's no certainty.
py__bases__() Returns a list of base classes.
@@ -168,9 +168,9 @@ class ClassContext(use_metaclass(CachedMetaClass, TreeContext)):
else:
return [LazyKnownContext(compiled.builtin_from_name(self.evaluator, u'object'))]
def py__call__(self, params):
def py__call__(self, arguments):
from jedi.evaluate.context import TreeInstance
return ContextSet(TreeInstance(self.evaluator, self.parent_context, self, params))
return ContextSet(TreeInstance(self.evaluator, self.parent_context, self, arguments))
def py__class__(self):
return compiled.builtin_from_name(self.evaluator, u'type')

View File

@@ -7,6 +7,7 @@ from jedi import debug
from jedi.evaluate.compiled import builtin_from_name, CompiledObject
from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS, Context
from jedi.evaluate.context.iterable import SequenceLiteralContext
from jedi.evaluate.arguments import repack_with_argument_clinic
from jedi.evaluate.filters import FilterWrapper, NameWrapper, \
AbstractTreeName
@@ -58,7 +59,7 @@ class TypingModuleName(NameWrapper):
evaluator = self.parent_context.evaluator
if name in (_PROXY_CLASS_TYPES + _TYPE_ALIAS_TYPES):
yield TypingClassContext(self)
elif name == _PROXY_TYPES:
elif name in _PROXY_TYPES:
yield TypingContext(self)
elif name == 'runtime':
# We don't want anything here, not sure what this function is
@@ -75,7 +76,7 @@ class TypingModuleName(NameWrapper):
yield builtin_from_name(evaluator, u'True')
elif name == 'overload':
# TODO implement overload
pass
yield OverloadFunction(self)
elif name == 'cast':
# TODO implement cast
for c in self._wrapped_name.infer(): # Fuck my life Python 2
@@ -305,3 +306,10 @@ class TypeVar(Context):
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self._name)
class OverloadFunction(_BaseTypingContext):
@repack_with_argument_clinic('func, /')
def py__call__(self, func_context_set):
debug.warning('overload used')
return NO_CONTEXTS