1
0
forked from VimPlug/jedi

Fix dynamic params.

This commit is contained in:
Dave Halter
2016-11-26 16:53:44 +01:00
parent c1b7acc9ac
commit 898fefcb17
4 changed files with 18 additions and 20 deletions

View File

@@ -513,16 +513,14 @@ class Evaluator(object):
def create_context(self, base_context, node):
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:
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):
return AnonymousInstanceFunctionExecution(
parent_context,

View File

@@ -100,9 +100,13 @@ def _check_for_setattr(instance):
"""
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:
stmts = module.used_names['setattr']
stmts = module.module_node.used_names['setattr']
except KeyError:
return False
@@ -117,14 +121,10 @@ def add_attribute_error(evaluator, scope, name):
# instead of an error, if that happens.
if isinstance(scope, AbstractInstanceContext):
typ = Warning
try:
scope.get_subscope_by_name('__getattr__')
except KeyError:
try:
scope.get_subscope_by_name('__getattribute__')
except KeyError:
if not _check_for_setattr(scope):
typ = Error
if not (scope.get_function_slot_names('__getattr__') or
scope.get_function_slot_names('__getattribute__')):
if not _check_for_setattr(scope):
typ = Error
else:
typ = Error

View File

@@ -182,7 +182,7 @@ def _check_name_for_execution(evaluator, context, compare_node, name, trailer):
if len(params) != 1:
continue
values = params[0].infer()
nodes = [value.get_node() for value in values]
nodes = [v.get_node() for v in values]
if nodes == [compare_node]:
# Found a decorator.
module_context = context.get_root_context()

View File

@@ -258,7 +258,7 @@ class BoundMethod(er.FunctionContext):
def get_function_execution(self, arguments):
return InstanceFunctionExecution(
self._instance,
self.parent_context,
self._class_context.parent_context,
self.funcdef,
arguments
)