forked from VimPlug/jedi
lots of small bugfixes
This commit is contained in:
@@ -138,8 +138,10 @@ class BaseDefinition(object):
|
||||
"""
|
||||
# generate the type
|
||||
stripped = self._definition
|
||||
if isinstance(self._definition, er.InstanceElement):
|
||||
stripped = self._definition.var
|
||||
if isinstance(stripped, compiled.PyObject):
|
||||
return stripped.type()
|
||||
if isinstance(stripped, er.InstanceElement):
|
||||
stripped = stripped.var
|
||||
if isinstance(stripped, pr.Name):
|
||||
stripped = stripped.parent
|
||||
return type(stripped).__name__.lower()
|
||||
@@ -438,7 +440,9 @@ class Definition(BaseDefinition):
|
||||
if isinstance(d, er.InstanceElement):
|
||||
d = d.var
|
||||
|
||||
if isinstance(d, pr.Name):
|
||||
if isinstance(d, compiled.PyObject):
|
||||
return d.name
|
||||
elif isinstance(d, pr.Name):
|
||||
return d.names[-1] if d.names else None
|
||||
elif isinstance(d, iterable.Array):
|
||||
return unicode(d.type)
|
||||
@@ -457,7 +461,6 @@ class Definition(BaseDefinition):
|
||||
return d.assignment_details[0][1].values[0][0].name.names[-1]
|
||||
except IndexError:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
|
||||
@@ -452,8 +452,6 @@ def filter_private_variable(scope, call_scope, var_name):
|
||||
if isinstance(var_name, (str, unicode)) and isinstance(scope, er.Instance)\
|
||||
and var_name.startswith('__') and not var_name.endswith('__'):
|
||||
s = call_scope.get_parent_until((pr.Class, er.Instance, compiled.PyObject))
|
||||
#if s != scope and (isinstance(scope.base, compiled.PyObject)
|
||||
# or s != scope.base.base):
|
||||
if s != scope:
|
||||
if isinstance(scope.base, compiled.PyObject):
|
||||
if s != scope.base:
|
||||
|
||||
@@ -126,6 +126,9 @@ class PyName(object):
|
||||
self.name = name
|
||||
self.start_pos = 0, 0 # an illegal start_pos, to make sorting easy.
|
||||
|
||||
def get_parent_until(self):
|
||||
return self.parent.get_parent_until()
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: (%s).%s>' % (type(self).__name__, repr(self._obj.obj), self.name)
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ from pytest import raises
|
||||
|
||||
def test_preload_modules():
|
||||
def check_loaded(*modules):
|
||||
# + 1 for builtin, +1 for None module (currently used)
|
||||
assert len(new) == len(modules) + 2
|
||||
# +1 for None module (currently used)
|
||||
assert len(new) == len(modules) + 1
|
||||
for i in modules + ('__builtin__',):
|
||||
assert [i in k for k in new.keys() if k is not None]
|
||||
|
||||
@@ -20,9 +20,8 @@ def test_preload_modules():
|
||||
new['__builtin__'] = temp_cache['__builtin__']
|
||||
|
||||
api.preload_module('datetime')
|
||||
check_loaded('datetime')
|
||||
api.preload_module('json', 'token')
|
||||
check_loaded('datetime', 'json', 'token')
|
||||
check_loaded('json', 'token')
|
||||
|
||||
cache.parser_cache = temp_cache
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ def test_is_keyword():
|
||||
results = Script('str', 1, 1, None).goto_definitions()
|
||||
assert len(results) == 1 and results[0].is_keyword is False
|
||||
|
||||
|
||||
def make_definitions():
|
||||
"""
|
||||
Return a list of definitions for parametrized tests.
|
||||
|
||||
Reference in New Issue
Block a user