mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Fix namedtuple and property issues
This commit is contained in:
@@ -13,7 +13,7 @@ from jedi.evaluate.arguments import AnonymousArguments
|
|||||||
from jedi.evaluate.filters import ParserTreeFilter, FunctionExecutionFilter, \
|
from jedi.evaluate.filters import ParserTreeFilter, FunctionExecutionFilter, \
|
||||||
ContextName, AbstractNameDefinition, ParamName
|
ContextName, AbstractNameDefinition, ParamName
|
||||||
from jedi.evaluate.base_context import ContextualizedNode, NO_CONTEXTS, \
|
from jedi.evaluate.base_context import ContextualizedNode, NO_CONTEXTS, \
|
||||||
ContextSet, TreeContext
|
ContextSet, TreeContext, ContextWrapper
|
||||||
from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \
|
from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \
|
||||||
LazyTreeContext
|
LazyTreeContext
|
||||||
from jedi.evaluate.context.typing import TypeVar
|
from jedi.evaluate.context.typing import TypeVar
|
||||||
@@ -296,14 +296,14 @@ class FunctionExecutionContext(TreeContext):
|
|||||||
return self.get_return_values()
|
return self.get_return_values()
|
||||||
|
|
||||||
|
|
||||||
class OverloadedFunctionContext(object):
|
class OverloadedFunctionContext(ContextWrapper):
|
||||||
def __init__(self, function, overloaded_functions):
|
def __init__(self, function, overloaded_functions):
|
||||||
self._function = function
|
super(OverloadedFunctionContext, self).__init__(function)
|
||||||
self._overloaded_functions = overloaded_functions
|
self._overloaded_functions = overloaded_functions
|
||||||
|
|
||||||
def py__call__(self, arguments):
|
def py__call__(self, arguments):
|
||||||
context_set = ContextSet()
|
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:
|
for f in self._overloaded_functions:
|
||||||
signature = parser_utils.get_call_signature(f.tree_node)
|
signature = parser_utils.get_call_signature(f.tree_node)
|
||||||
if signature_matches(f, arguments):
|
if signature_matches(f, arguments):
|
||||||
@@ -315,9 +315,6 @@ class OverloadedFunctionContext(object):
|
|||||||
signature, f.tree_node.start_pos[0], arguments, color='BLUE')
|
signature, f.tree_node.start_pos[0], arguments, color='BLUE')
|
||||||
return context_set
|
return context_set
|
||||||
|
|
||||||
def __getattr__(self, name):
|
|
||||||
return getattr(self._function, name)
|
|
||||||
|
|
||||||
|
|
||||||
def signature_matches(function_context, arguments):
|
def signature_matches(function_context, arguments):
|
||||||
unpacked_arguments = arguments.unpack()
|
unpacked_arguments = arguments.unpack()
|
||||||
|
|||||||
@@ -123,17 +123,13 @@ def argument_clinic(string, want_obj=False, want_context=False,
|
|||||||
|
|
||||||
@argument_clinic('obj, type, /', want_obj=True, want_arguments=True)
|
@argument_clinic('obj, type, /', want_obj=True, want_arguments=True)
|
||||||
def builtins_property(objects, types, obj, arguments):
|
def builtins_property(objects, types, obj, arguments):
|
||||||
print(obj)
|
|
||||||
print(obj.instance.var_args)
|
|
||||||
property_args = obj.instance.var_args.unpack()
|
property_args = obj.instance.var_args.unpack()
|
||||||
key, lazy_context = next(property_args, (None, None))
|
key, lazy_context = next(property_args, (None, None))
|
||||||
if key is not None or lazy_context is None:
|
if key is not None or lazy_context is None:
|
||||||
debug.warning('property expected a first param, not %s', arguments)
|
debug.warning('property expected a first param, not %s', arguments)
|
||||||
return NO_CONTEXTS
|
return NO_CONTEXTS
|
||||||
print('lazy_context', lazy_context, lazy_context.infer())
|
|
||||||
print()
|
return lazy_context.infer().py__call__(arguments=ValuesArguments([objects]))
|
||||||
print(objects, type)
|
|
||||||
return NO_CONTEXTS
|
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('iterator[, default], /', want_evaluator=True)
|
@argument_clinic('iterator[, default], /', want_evaluator=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user