Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 781
Tom Ellis Avatar asked Nov 08 '22 19:11

Tom Ellis


1 Answers

I tried to use pylint_flask, but it doesn't work.

pylint --load-plugins pylint_flask makerpose/appserver.py

Adding _ in front of methods' names solves the problem.

like image 135
tuanzi88 Avatar answered Nov 15 '22 05:11

tuanzi88