forked from VimPlug/jedi
dive further into following imports, etc
This commit is contained in:
@@ -6,12 +6,13 @@ from jedi import debug
|
||||
|
||||
|
||||
CODES = {
|
||||
'inaccesible': (1, 'Attribute is not accessible.'),
|
||||
'attribute-error': (1, 'Potential AttributeError.'),
|
||||
}
|
||||
|
||||
|
||||
class Error(object):
|
||||
def __init__(self, name, start_pos):
|
||||
def __init__(self, name, module_path, start_pos):
|
||||
self._module_path = module_path
|
||||
self._start_pos = start_pos
|
||||
self.name = name
|
||||
|
||||
@@ -32,12 +33,18 @@ class Error(object):
|
||||
def __str__(self):
|
||||
return '%s: %s' % (self.code, self.line)
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s %s: %s@%s,%s' % (self.__class__.__name__,
|
||||
self.name, self._module_path,
|
||||
self._start_pos[0], self._start_pos[1])
|
||||
|
||||
|
||||
class Warning(Error):
|
||||
pass
|
||||
|
||||
|
||||
def add(evaluator, code, typ=Error):
|
||||
instance = typ()
|
||||
debug.warning(str(Error))
|
||||
def add(evaluator, name, jedi_obj, typ=Error):
|
||||
module_path = jedi_obj.get_parent_until().path
|
||||
instance = typ(name, module_path, jedi_obj.start_pos)
|
||||
debug.warning(str(instance))
|
||||
evaluator.analysis.append(instance)
|
||||
|
||||
@@ -24,6 +24,7 @@ from jedi.evaluate import compiled
|
||||
from jedi.evaluate import docstrings
|
||||
from jedi.evaluate import iterable
|
||||
from jedi.evaluate import imports
|
||||
from jedi.evaluate import analysis
|
||||
|
||||
|
||||
class NameFinder(object):
|
||||
@@ -193,6 +194,14 @@ class NameFinder(object):
|
||||
# handling __getattr__ / __getattribute__
|
||||
types = self._check_getattr(self.scope)
|
||||
|
||||
if not names and not types \
|
||||
and not (isinstance(self.name_str, pr.NamePart)
|
||||
and isinstance(self.name_str.parent.parent, pr.Param)):
|
||||
if not isinstance(self.name_str, (str, unicode)): # TODO Remove
|
||||
analysis.add(self._evaluator, 'attribute-error', self.name_str)
|
||||
print(self.scope, self.name_str.parent.parent, self.name_str, self.position,
|
||||
self.name_str.start_pos)
|
||||
|
||||
return types
|
||||
|
||||
def _remove_statements(self, stmt):
|
||||
|
||||
Reference in New Issue
Block a user