forked from VimPlug/jedi
Fix dynamic params.
This commit is contained in:
@@ -513,16 +513,14 @@ class Evaluator(object):
|
|||||||
|
|
||||||
def create_context(self, base_context, node):
|
def create_context(self, base_context, node):
|
||||||
def from_scope_node(scope_node, child_is_funcdef=None):
|
def from_scope_node(scope_node, child_is_funcdef=None):
|
||||||
is_funcdef = scope_node.type == 'funcdef'
|
|
||||||
parent_context = None
|
|
||||||
parent_scope = scope_node.get_parent_scope()
|
|
||||||
if parent_scope is not None:
|
|
||||||
parent_context = from_scope_node(parent_scope, child_is_funcdef=is_funcdef)
|
|
||||||
|
|
||||||
# TODO this whole procedure just ignores decorators
|
|
||||||
if scope_node == base_node:
|
if scope_node == base_node:
|
||||||
return base_context
|
return base_context
|
||||||
elif is_funcdef:
|
|
||||||
|
is_funcdef = scope_node.type == 'funcdef'
|
||||||
|
parent_scope = scope_node.get_parent_scope()
|
||||||
|
parent_context = from_scope_node(parent_scope, child_is_funcdef=is_funcdef)
|
||||||
|
|
||||||
|
if is_funcdef:
|
||||||
if isinstance(parent_context, AnonymousInstance):
|
if isinstance(parent_context, AnonymousInstance):
|
||||||
return AnonymousInstanceFunctionExecution(
|
return AnonymousInstanceFunctionExecution(
|
||||||
parent_context,
|
parent_context,
|
||||||
|
|||||||
@@ -100,9 +100,13 @@ def _check_for_setattr(instance):
|
|||||||
"""
|
"""
|
||||||
Check if there's any setattr method inside an instance. If so, return True.
|
Check if there's any setattr method inside an instance. If so, return True.
|
||||||
"""
|
"""
|
||||||
module = instance.get_parent_until()
|
from jedi.evaluate.representation import ModuleContext
|
||||||
|
module = instance.get_root_context()
|
||||||
|
if not isinstance(module, ModuleContext):
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stmts = module.used_names['setattr']
|
stmts = module.module_node.used_names['setattr']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -117,12 +121,8 @@ def add_attribute_error(evaluator, scope, name):
|
|||||||
# instead of an error, if that happens.
|
# instead of an error, if that happens.
|
||||||
if isinstance(scope, AbstractInstanceContext):
|
if isinstance(scope, AbstractInstanceContext):
|
||||||
typ = Warning
|
typ = Warning
|
||||||
try:
|
if not (scope.get_function_slot_names('__getattr__') or
|
||||||
scope.get_subscope_by_name('__getattr__')
|
scope.get_function_slot_names('__getattribute__')):
|
||||||
except KeyError:
|
|
||||||
try:
|
|
||||||
scope.get_subscope_by_name('__getattribute__')
|
|
||||||
except KeyError:
|
|
||||||
if not _check_for_setattr(scope):
|
if not _check_for_setattr(scope):
|
||||||
typ = Error
|
typ = Error
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ def _check_name_for_execution(evaluator, context, compare_node, name, trailer):
|
|||||||
if len(params) != 1:
|
if len(params) != 1:
|
||||||
continue
|
continue
|
||||||
values = params[0].infer()
|
values = params[0].infer()
|
||||||
nodes = [value.get_node() for value in values]
|
nodes = [v.get_node() for v in values]
|
||||||
if nodes == [compare_node]:
|
if nodes == [compare_node]:
|
||||||
# Found a decorator.
|
# Found a decorator.
|
||||||
module_context = context.get_root_context()
|
module_context = context.get_root_context()
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ class BoundMethod(er.FunctionContext):
|
|||||||
def get_function_execution(self, arguments):
|
def get_function_execution(self, arguments):
|
||||||
return InstanceFunctionExecution(
|
return InstanceFunctionExecution(
|
||||||
self._instance,
|
self._instance,
|
||||||
self.parent_context,
|
self._class_context.parent_context,
|
||||||
self.funcdef,
|
self.funcdef,
|
||||||
arguments
|
arguments
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user