Flask: Idiomatic way to stop pylint complaining about flask route unused function names?

Created on 28 Jul 2017  路  3Comments  路  Source: pallets/flask

My Python Flask application contains a lot of route definitions like

@app.route('/')
def index():

Then pylint complains

W: 72, 4: Unused variable 'index' (unused-variable)

which is technically correct. I can't replace all the function names by _, say, because then Flask complains

AssertionError: View function mapping is overwriting an existing endpoint function: _

I could replace all the handler function names with their underscore-prefixed equivalents, i.e. change index to _index, etc.. Is there another idiomatic way of dealing with this problem?

(I also asked this question on StackOverflow but got no responses.)

Most helpful comment

What do Flask-and-pylint-using people normally do? This issue must come up a lot.

All 3 comments

I think the proper solution would be for pylint to add an option to list decorators that "register" functions so they are not considered unused.

What do Flask-and-pylint-using people normally do? This issue must come up a lot.

@tomjaguarpaw I'd love to see @ThiefMaster's suggestion added as a plugin or rule. pylint-flask package appears to not do this, https://github.com/jschaf/pylint-flask/issues/7#issuecomment-318673953.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sungjinp11 picture sungjinp11  路  3Comments

fb picture fb  路  5Comments

wadegilmer picture wadegilmer  路  4Comments

jab picture jab  路  4Comments

ghostbod99 picture ghostbod99  路  4Comments