mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
None issue fix for static analysis
This commit is contained in:
@@ -7,7 +7,6 @@ from jedi.parser import representation as pr
|
|||||||
from jedi.evaluate.compiled import CompiledObject
|
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.'),
|
'import-error': (2, ImportError, 'Potential ImportError.'),
|
||||||
@@ -36,7 +35,7 @@ class Error(object):
|
|||||||
return first + str(CODES[self.name][0])
|
return first + str(CODES[self.name][0])
|
||||||
|
|
||||||
def description(self):
|
def description(self):
|
||||||
return CODES[self.name][1]
|
return CODES[self.name][2]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s: %s:%s' % (self.code, self.line, self.description())
|
return '%s: %s:%s' % (self.code, self.line, self.description())
|
||||||
|
|||||||
@@ -308,12 +308,6 @@ def _parse_function_doc(doc):
|
|||||||
|
|
||||||
|
|
||||||
class Builtin(CompiledObject, IsScope):
|
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
|
@memoize
|
||||||
def get_by_name(self, name):
|
def get_by_name(self, name):
|
||||||
item = [n for n in self.get_defined_names() if n.get_code() == name][0]
|
item = [n for n in self.get_defined_names() if n.get_code() == name][0]
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ class NameFinder(object):
|
|||||||
self.position = position
|
self.position = position
|
||||||
|
|
||||||
def find(self, scopes, resolve_decorator=True):
|
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)
|
names = self.filter_name(scopes)
|
||||||
types = self._names_to_types(names, resolve_decorator)
|
types = self._names_to_types(names, resolve_decorator)
|
||||||
|
|
||||||
|
|||||||
@@ -36,3 +36,6 @@ Cls.class_attr_error
|
|||||||
c.instance_attr
|
c.instance_attr
|
||||||
#! attribute-error
|
#! attribute-error
|
||||||
c.instance_attr_error
|
c.instance_attr_error
|
||||||
|
|
||||||
|
|
||||||
|
c.something = None
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ except ImportError:
|
|||||||
pass
|
pass
|
||||||
except (NotImplementedError, AttributeError): pass
|
except (NotImplementedError, AttributeError): pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
#! attribute-error
|
||||||
|
str.not_existing
|
||||||
|
except (TypeError, NotImplementedError): pass
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# detailed except
|
# detailed except
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user