Get finally rid of context.type.

This commit is contained in:
Dave Halter
2016-11-26 10:32:44 +01:00
parent 2161be2dcb
commit c1b7acc9ac
3 changed files with 14 additions and 17 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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: