[Python-projects] Strange pylint error

JT Olds jtolds at xnet5.com
Fri Aug 17 23:06:27 CEST 2012


Hey all,

I'm getting a weird error from pylint. I've reduced the code that
makes pylint choke to a small test case. When I run pylint on

class Thing2(object):
    def decorator(self, method):
        def wrapper(*args, **kwargs):
            return method(*args, **kwargs)
        return wrapper

class Thing1(object):
    def __getattr__(self, name):
        return Thing2()

thing = Thing1()

@thing.my_param.decorator
def test():
    print "hi"

I get:

Traceback (most recent call last):
  File "/home/jt/.virtualenvs/default/bin/pylint", line 4, in <module>
    lint.Run(sys.argv[1:])
  File "/home/jt/.virtualenvs/default/local/lib/python2.7/site-packages/pylint/lint.py",
line 879, in __init__
    linter.check(args)
  File "/home/jt/.virtualenvs/default/local/lib/python2.7/site-packages/pylint/lint.py",
line 502, in check
    self.check_astng_module(astng, walker, rawcheckers)
  File "/home/jt/.virtualenvs/default/local/lib/python2.7/site-packages/pylint/lint.py",
line 574, in check_astng_module
    walker.walk(astng)
  File "/home/jt/.virtualenvs/default/local/lib/python2.7/site-packages/pylint/utils.py",
line 528, in walk
    self.walk(child)
  File "/home/jt/.virtualenvs/default/local/lib/python2.7/site-packages/pylint/utils.py",
line 525, in walk
    cb(astng)
  File "/home/jt/.virtualenvs/default/local/lib/python2.7/site-packages/pylint/checkers/base.py",
line 161, in visit_function
    if not redefined_by_decorator(node):
  File "/home/jt/.virtualenvs/default/local/lib/python2.7/site-packages/pylint/checkers/base.py",
line 116, in redefined_by_decorator
    decorator.expr.name == node.name):
AttributeError: 'Getattr' object has no attribute 'name'

Any ideas?



More information about the Python-Projects mailing list