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.)
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.
Most helpful comment
What do Flask-and-pylint-using people normally do? This issue must come up a lot.