From c1b7acc9acaf0a8c7a101073727757fc5a674c5a Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 26 Nov 2016 10:32:44 +0100 Subject: [PATCH] Get finally rid of context.type. --- jedi/evaluate/context.py | 1 - jedi/evaluate/filters.py | 21 +++++++++------------ jedi/evaluate/iterable.py | 9 +++++---- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/jedi/evaluate/context.py b/jedi/evaluate/context.py index 9e2a4412..f00e8bba 100644 --- a/jedi/evaluate/context.py +++ b/jedi/evaluate/context.py @@ -2,7 +2,6 @@ from jedi.common import unite class Context(object): - type = None # TODO remove api_type = 'instance' """ Most contexts are just instances of something, therefore make this the diff --git a/jedi/evaluate/filters.py b/jedi/evaluate/filters.py index 1b584671..886ef254 100644 --- a/jedi/evaluate/filters.py +++ b/jedi/evaluate/filters.py @@ -237,19 +237,16 @@ def get_global_filters(evaluator, context, until_position, origin_scope): Returns all filters in order of priority for name resolution. """ from jedi.evaluate.representation import FunctionExecutionContext - in_func = False while context is not None: - if not (context.type == 'classdef' and in_func): - # Names in methods cannot be resolved within the class. - for filter in context.get_filters( - search_global=True, - until_position=until_position, - origin_scope=origin_scope): - yield filter - if isinstance(context, FunctionExecutionContext): - # The position should be reset if the current scope is a function. - until_position = None - in_func = True + # Names in methods cannot be resolved within the class. + for filter in context.get_filters( + search_global=True, + until_position=until_position, + origin_scope=origin_scope): + yield filter + if isinstance(context, FunctionExecutionContext): + # The position should be reset if the current scope is a function. + until_position = None context = context.parent_context diff --git a/jedi/evaluate/iterable.py b/jedi/evaluate/iterable.py index be4cf5c2..9bd14f32 100644 --- a/jedi/evaluate/iterable.py +++ b/jedi/evaluate/iterable.py @@ -546,7 +546,7 @@ class FakeDict(_FakeArray): class MergedArray(_FakeArray): def __init__(self, evaluator, arrays): - super(MergedArray, self).__init__(evaluator, arrays, arrays[-1].type) + super(MergedArray, self).__init__(evaluator, arrays, arrays[-1].array_type) self._arrays = arrays def py__iter__(self): @@ -660,7 +660,7 @@ def py__getitem__(evaluator, context, types, trailer): # If the index is not clearly defined, we have to get all the # possiblities. for typ in list(types): - if isinstance(typ, AbstractSequence) and typ.type == 'dict': + if isinstance(typ, AbstractSequence) and typ.array_type == 'dict': types.remove(typ) result |= typ.dict_values() return result | py__iter__types(evaluator, types) @@ -685,11 +685,12 @@ def py__getitem__(evaluator, context, types, trailer): def check_array_additions(evaluator, array): """ Just a mapper function for the internal _check_array_additions """ - if array.type not in ('list', 'set'): + if array.array_type not in ('list', 'set'): # TODO also check for dict updates return set() - is_list = array.type == 'list' + return set() + is_list = array.array_type == 'list' try: current_module = array.atom.get_parent_until() except AttributeError: