Using pylint on the following script:
import ctypes
class _MetaEnum(ctypes.c_long.__class__):
'''Meta class for Enum'''
def __init__(mcs, name, bases, newattrs):
super(_MetaEnum, mcs).__init__(name, bases, newattrs)
itemValue = -1
mcs._strings_ = {} #pylint: disable=C0103
for field in getattr(mcs, '_fields_'):
if len(field) == 1:
itemValue += 1
else:
itemValue = field[1]
setattr(mcs, field[0], itemValue)
mcs._strings_[itemValue] = field[0]
class Enum(ctypes.c_long):
'''Enum class'''
_fields_ = []
__metaclass__ = _MetaEnum
def __init__(self, idOrString = 0):
cls = type(self)
self.set(idOrString)
Results in:
Traceback (most recent call last):
File "s:\devenv\devtools_release\pylint.bat", line 14, in
lint.Run(sys.argv[1:])
File "s:\devenv\tools_3rdparty\python\lib\site-packages\pylint\lint.py", line 856, in __init__
linter.check(args)
File "s:\devenv\tools_3rdparty\python\lib\site-packages\pylint\lint.py", line 488, in check
self.check_astng_module(astng, walker, rawcheckers)
File "s:\devenv\tools_3rdparty\python\lib\site-packages\pylint\lint.py", line 563, in check_astng_module
walker.walk(astng)
File "s:\devenv\tools_3rdparty\python\lib\site-packages\pylint\utils.py", line 516, in walk
self.walk(child)
File "s:\devenv\tools_3rdparty\python\lib\site-packages\pylint\utils.py", line 513, in walk
cb(astng)
File "s:\devenv\tools_3rdparty\python\lib\site-packages\pylint\checkers\design_analysis.py", line 191, in visit_class
nb_parents = len(list(node.ancestors()))
File "s:\devenv\tools_3rdparty\python\lib\site-packages\logilab\astng\scoped_nodes.py", line 757, in ancestors
for grandpa in baseobj.ancestors(True, context):
File "s:\devenv\tools_3rdparty\python\lib\site-packages\logilab\astng\scoped_nodes.py", line 749, in ancestors
for baseobj in stmt.infer(context):
File "s:\devenv\tools_3rdparty\python\lib\site-packages\logilab\astng\bases.py", line 303, in wrapped
for res in _func(node, context, **kwargs):
File "s:\devenv\tools_3rdparty\python\lib\site-packages\logilab\astng\inference.py", line 175, in infer_name
frame, stmts = self.lookup(self.name)
File "s:\devenv\tools_3rdparty\python\lib\site-packages\logilab\astng\node_classes.py", line 114, in lookup
return self.scope().scope_lookup(self, name)
File "s:\devenv\tools_3rdparty\python\lib\site-packages\logilab\astng\scoped_nodes.py", line 720, in scope_lookup
frame = self.parent.frame()
AttributeError: 'NoneType' object has no attribute 'frame'
|
Comments
-
2010/09/15 12:20, written by cedric
I've put the exception raisin line in a try except block, adding the following code:
which results in the following error:
-
2010/09/17 11:43, written by cedric
I've solved mine issue by changing the following
into
I hope what i did was right? But it's working for me now.
add comment