Fix namedtuple and property issues

This commit is contained in:
Dave Halter
2018-09-04 00:27:40 +02:00
parent 38176ae7e6
commit f432a0b7c4
2 changed files with 6 additions and 13 deletions

View File

@@ -13,7 +13,7 @@ from jedi.evaluate.arguments import AnonymousArguments
from jedi.evaluate.filters import ParserTreeFilter, FunctionExecutionFilter, \
ContextName, AbstractNameDefinition, ParamName
from jedi.evaluate.base_context import ContextualizedNode, NO_CONTEXTS, \
ContextSet, TreeContext
ContextSet, TreeContext, ContextWrapper
from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \
LazyTreeContext
from jedi.evaluate.context.typing import TypeVar
@@ -296,14 +296,14 @@ class FunctionExecutionContext(TreeContext):
return self.get_return_values()
class OverloadedFunctionContext(object):
class OverloadedFunctionContext(ContextWrapper):
def __init__(self, function, overloaded_functions):
self._function = function
super(OverloadedFunctionContext, self).__init__(function)
self._overloaded_functions = overloaded_functions
def py__call__(self, arguments):
context_set = ContextSet()
debug.dbg("Execute overloaded function %s", self._function, color='BLUE')
debug.dbg("Execute overloaded function %s", self._wrapped_context, color='BLUE')
for f in self._overloaded_functions:
signature = parser_utils.get_call_signature(f.tree_node)
if signature_matches(f, arguments):
@@ -315,9 +315,6 @@ class OverloadedFunctionContext(object):
signature, f.tree_node.start_pos[0], arguments, color='BLUE')
return context_set
def __getattr__(self, name):
return getattr(self._function, name)
def signature_matches(function_context, arguments):
unpacked_arguments = arguments.unpack()

View File

@@ -123,17 +123,13 @@ def argument_clinic(string, want_obj=False, want_context=False,
@argument_clinic('obj, type, /', want_obj=True, want_arguments=True)
def builtins_property(objects, types, obj, arguments):
print(obj)
print(obj.instance.var_args)
property_args = obj.instance.var_args.unpack()
key, lazy_context = next(property_args, (None, None))
if key is not None or lazy_context is None:
debug.warning('property expected a first param, not %s', arguments)
return NO_CONTEXTS
print('lazy_context', lazy_context, lazy_context.infer())
print()
print(objects, type)
return NO_CONTEXTS
return lazy_context.infer().py__call__(arguments=ValuesArguments([objects]))
@argument_clinic('iterator[, default], /', want_evaluator=True)