None issue fix for static analysis

This commit is contained in:
Dave Halter
2014-05-13 01:21:32 +02:00
parent 00e43d4585
commit a2b483b4f5
5 changed files with 14 additions and 8 deletions

View File

@@ -7,7 +7,6 @@ from jedi.parser import representation as pr
from jedi.evaluate.compiled import CompiledObject
CODES = {
'attribute-error': (1, AttributeError, 'Potential AttributeError.'),
'import-error': (2, ImportError, 'Potential ImportError.'),
@@ -36,7 +35,7 @@ class Error(object):
return first + str(CODES[self.name][0])
def description(self):
return CODES[self.name][1]
return CODES[self.name][2]
def __str__(self):
return '%s: %s:%s' % (self.code, self.line, self.description())

View File

@@ -308,12 +308,6 @@ def _parse_function_doc(doc):
class Builtin(CompiledObject, IsScope):
@memoize
def get_defined_names(self):
# Filter None, because it's really just a keyword, nobody wants to
# access it.
return [d for d in super(Builtin, self).get_defined_names() if d.name != 'None']
@memoize
def get_by_name(self, name):
item = [n for n in self.get_defined_names() if n.get_code() == name][0]

View File

@@ -35,6 +35,11 @@ class NameFinder(object):
self.position = position
def find(self, scopes, resolve_decorator=True):
if unicode(self.name_str) == 'None':
# Filter None, because it's really just a keyword, nobody wants to
# access it.
return []
names = self.filter_name(scopes)
types = self._names_to_types(names, resolve_decorator)

View File

@@ -36,3 +36,6 @@ Cls.class_attr_error
c.instance_attr
#! attribute-error
c.instance_attr_error
c.something = None

View File

@@ -34,6 +34,11 @@ except ImportError:
pass
except (NotImplementedError, AttributeError): pass
try:
#! attribute-error
str.not_existing
except (TypeError, NotImplementedError): pass
# -----------------
# detailed except
# -----------------