andy boot
andy boot

Reputation: 11757

Pylint and Tornado - fails on @tornado.web.authenticated

Pylint crashes when it encounters @tornado.web.authenticated

class Handler1(tornado.web.RequestHandler):
    def get(self):
        return 'hello'

class Handler2(tornado.web.RequestHandler):
    @tornado.web.authenticated
    def get(self):
        return 'hello'

Pylint runs on a file containing Handler1. Pylint crashes on a file containing Handler2 reporting: decorator.expr.name == node.name): AttributeError: 'Getattr' object has no attribute 'name'

Traceback (most recent call last):
   File "/Users/andy/dev/virtualenv/thanks-app/bin/pylint", line 4, in <module>
    lint.Run(sys.argv[1:])
   File "/Users/andy/dev/virtualenv/thanks-app/lib/python2.7/site-packages/pylint/lint.py", line 879, in __init__
    linter.check(args)
   File "/Users/andy/dev/virtualenv/thanks-app/lib/python2.7/site-packages/pylint/lint.py", line 502, in check
    self.check_astng_module(astng, walker, rawcheckers)
   File "/Users/andy/dev/virtualenv/thanks-app/lib/python2.7/site-packages/pylint/lint.py", line 574, in check_astng_module
    walker.walk(astng)
   File "/Users/andy/dev/virtualenv/thanks-app/lib/python2.7/site-packages/pylint/utils.py", line 528, in walk
    self.walk(child)
   File "/Users/andy/dev/virtualenv/thanks-app/lib/python2.7/site-packages/pylint/utils.py", line 528, in walk
    self.walk(child)
   File "/Users/andy/dev/virtualenv/thanks-app/lib/python2.7/site-packages/pylint/utils.py", line 525, in walk
    cb(astng)
   File "/Users/andy/dev/virtualenv/thanks-app/lib/python2.7/site-packages/pylint/checkers/base.py", line 161, in visit_function
    if not redefined_by_decorator(node):
   File "/Users/andy/dev/virtualenv/thanks-app/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'

Is there a specific Pylint check that I can disable to stop this crash occurring?

I'm using:

Upvotes: 1

Views: 263

Answers (2)

sthenault
sthenault

Reputation: 15125

This bug has been fixed in pylint repository and will soon be released (0.26 should be out next week). So either use a checkout (hg clone http://hg.logilab.org/pylint) or wait until next week

Upvotes: 1

andy boot
andy boot

Reputation: 11757

Looked through the code here. Disabling these has stopped the error occurring: [add these to config]

disable=E0100,E0101,E0102,E0106

pylint file -d E0100,E0101,E0102,E0106

Upvotes: 1

Related Questions