forked from VimPlug/jedi
Fix more argument related stuff.
This commit is contained in:
@@ -184,7 +184,7 @@ class Evaluator(object):
|
||||
"""
|
||||
if isinstance(atom, pr.Name):
|
||||
# This is the first global lookup.
|
||||
stmt = atom.get_parent_until((pr.ExprStmt, pr.ReturnStmt))
|
||||
stmt = atom.get_parent_until((pr.ExprStmt, pr.ReturnStmt, pr.Scope))
|
||||
return self.find_types(stmt.parent, atom, stmt.start_pos,
|
||||
search_global=True)
|
||||
elif isinstance(atom, pr.Literal):
|
||||
|
||||
@@ -21,8 +21,12 @@ class Arguments(object):
|
||||
def _split(self):
|
||||
if isinstance(self._argument_node, (tuple, list)):
|
||||
for el in self._argument_node:
|
||||
yield 0
|
||||
yield 0, el
|
||||
else:
|
||||
if not pr.is_node(self._argument_node, 'arglist'):
|
||||
yield 0, self._argument_node
|
||||
return
|
||||
|
||||
iterator = iter(self._argument_node.children)
|
||||
for child in iterator:
|
||||
if child == ',':
|
||||
|
||||
@@ -29,6 +29,7 @@ __
|
||||
import copy
|
||||
import os
|
||||
import pkgutil
|
||||
from itertools import chain
|
||||
|
||||
from jedi._compatibility import use_metaclass, unicode, Python3Method
|
||||
from jedi.parser import representation as pr
|
||||
@@ -235,8 +236,7 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
||||
return getattr(self.base, name)
|
||||
|
||||
def __repr__(self):
|
||||
return "<e%s of %s (var_args: %s)>" % \
|
||||
(type(self).__name__, self.base, len(self.var_args or []))
|
||||
return "<e%s of %s %s>" % (type(self).__name__, self.base, self.var_args)
|
||||
|
||||
|
||||
def get_instance_el(evaluator, instance, var, is_class_var=False):
|
||||
@@ -377,6 +377,10 @@ class Class(use_metaclass(CachedMetaClass, Wrapper)):
|
||||
|
||||
@memoize_default(default=())
|
||||
def py__bases__(self, evaluator):
|
||||
args = param.Arguments(self._evaluator, self.base.get_super_arglist() or ())
|
||||
return list(chain.from_iterable(args.eval_args()))
|
||||
|
||||
# TODO remove
|
||||
supers = []
|
||||
for s in self.base.supers:
|
||||
# Super classes are statements.
|
||||
|
||||
@@ -647,9 +647,11 @@ class Class(Scope):
|
||||
super(Class, self).__init__(children)
|
||||
self.decorators = []
|
||||
|
||||
@property
|
||||
def supers(self):
|
||||
raise NotImplementedError
|
||||
def get_super_arglist(self):
|
||||
if len(self.children) == 4: # Has no parentheses
|
||||
return None
|
||||
else:
|
||||
return self.children[3]
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
Reference in New Issue
Block a user