forked from VimPlug/jedi
static analysis is now able to tell the difference between NameError/AttributeError
This commit is contained in:
@@ -108,7 +108,7 @@ class Evaluator(object):
|
|||||||
scopes = f.scopes(search_global)
|
scopes = f.scopes(search_global)
|
||||||
if is_goto:
|
if is_goto:
|
||||||
return f.filter_name(scopes)
|
return f.filter_name(scopes)
|
||||||
return f.find(scopes, resolve_decorator)
|
return f.find(scopes, resolve_decorator, search_global)
|
||||||
|
|
||||||
@memoize_default(default=[], evaluator_is_first_arg=True)
|
@memoize_default(default=[], evaluator_is_first_arg=True)
|
||||||
@recursion.recursion_decorator
|
@recursion.recursion_decorator
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ from jedi.evaluate.compiled import CompiledObject
|
|||||||
|
|
||||||
CODES = {
|
CODES = {
|
||||||
'attribute-error': (1, AttributeError, 'Potential AttributeError.'),
|
'attribute-error': (1, AttributeError, 'Potential AttributeError.'),
|
||||||
'import-error': (2, ImportError, 'Potential ImportError.'),
|
'name-error': (2, NameError, 'Potential NameError.'),
|
||||||
'type-error-generator': (3, TypeError, "TypeError: 'generator' object is not subscriptable."),
|
'import-error': (3, ImportError, 'Potential ImportError.'),
|
||||||
|
'type-error-generator': (4, TypeError, "TypeError: 'generator' object is not subscriptable."),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class NameFinder(object):
|
|||||||
self.name_str = name_str
|
self.name_str = name_str
|
||||||
self.position = position
|
self.position = position
|
||||||
|
|
||||||
def find(self, scopes, resolve_decorator=True):
|
def find(self, scopes, resolve_decorator=True, search_global=False):
|
||||||
if unicode(self.name_str) == 'None':
|
if unicode(self.name_str) == 'None':
|
||||||
# Filter None, because it's really just a keyword, nobody wants to
|
# Filter None, because it's really just a keyword, nobody wants to
|
||||||
# access it.
|
# access it.
|
||||||
@@ -47,7 +47,8 @@ class NameFinder(object):
|
|||||||
and not (isinstance(self.name_str, pr.NamePart)
|
and not (isinstance(self.name_str, pr.NamePart)
|
||||||
and isinstance(self.name_str.parent.parent, pr.Param)):
|
and isinstance(self.name_str.parent.parent, pr.Param)):
|
||||||
if not isinstance(self.name_str, (str, unicode)): # TODO Remove
|
if not isinstance(self.name_str, (str, unicode)): # TODO Remove
|
||||||
analysis.add(self._evaluator, 'attribute-error', self.name_str)
|
err_type = 'name-error' if search_global else 'attribute-error'
|
||||||
|
analysis.add(self._evaluator, err_type, self.name_str)
|
||||||
|
|
||||||
debug.dbg('finder._names_to_types: %s, old: %s', names, types)
|
debug.dbg('finder._names_to_types: %s, old: %s', names, types)
|
||||||
return self._resolve_descriptors(types)
|
return self._resolve_descriptors(types)
|
||||||
|
|||||||
Reference in New Issue
Block a user