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