forked from VimPlug/jedi
Refactor some more typing related things
This commit is contained in:
@@ -128,14 +128,13 @@ class AbstractInstanceContext(Context):
|
||||
yield InstanceClassFilter(self.evaluator, self, cls, origin_scope)
|
||||
|
||||
def py__getitem__(self, index_context_set, contextualized_node):
|
||||
try:
|
||||
names = self.get_function_slot_names(u'__getitem__')
|
||||
except KeyError:
|
||||
names = self.get_function_slot_names(u'__getitem__')
|
||||
if not names:
|
||||
debug.warning('No __getitem__, cannot access the array.')
|
||||
return NO_CONTEXTS
|
||||
else:
|
||||
args = ValuesArguments([index_context_set])
|
||||
return ContextSet.from_sets(name.infer().execute(args) for name in names)
|
||||
|
||||
args = ValuesArguments([index_context_set])
|
||||
return ContextSet.from_sets(name.infer().execute(args) for name in names)
|
||||
|
||||
def py__iter__(self):
|
||||
iter_slot_names = self.get_function_slot_names(u'__iter__')
|
||||
|
||||
@@ -32,6 +32,14 @@ class _BaseTypingContext(Context):
|
||||
)
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def tree_node(self):
|
||||
return self._name.tree_name
|
||||
|
||||
def get_filters(self, *args, **kwargs):
|
||||
# TODO this is obviously wrong.
|
||||
return iter([])
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return TypingName(self, self._name)
|
||||
@@ -147,14 +155,6 @@ class TypingContext(_BaseTypingContext):
|
||||
|
||||
|
||||
class TypingClassMixin(object):
|
||||
@property
|
||||
def tree_node(self):
|
||||
return self.name.tree_name
|
||||
|
||||
def get_filters(self, *args, **kwargs):
|
||||
# TODO this is obviously wrong.
|
||||
return iter([])
|
||||
|
||||
def py__mro__(self):
|
||||
return (self,)
|
||||
|
||||
@@ -176,10 +176,6 @@ def _iter_over_arguments(maybe_tuple_context):
|
||||
|
||||
|
||||
class _ContainerBase(_WithIndexBase):
|
||||
def get_filters(self, *args, **kwargs):
|
||||
# TODO this is obviously wrong.
|
||||
return iter([])
|
||||
|
||||
def _get_getitem_contexts(self, index):
|
||||
for i, contexts in enumerate(_iter_over_arguments(self._index_context)):
|
||||
if i == index:
|
||||
|
||||
@@ -311,7 +311,7 @@ class StubModuleContext(_StubContextFilterMixin, ModuleContext):
|
||||
|
||||
class StubClassContext(_StubContextFilterMixin, ClassContext):
|
||||
def __getattribute__(self, name):
|
||||
if name == ('py__getitem__', 'py__bases__'):
|
||||
if name == ('py__getitem__', 'py__simple_getitem__', 'py__bases__'):
|
||||
# getitem is always done in the stub class.
|
||||
return getattr(self.stub_context, name)
|
||||
return super(StubClassContext, self).__getattribute__(name)
|
||||
|
||||
Reference in New Issue
Block a user