阻止 pylint 抱怨烧瓶路由未使用的函数名称的惯用方法?

Tom*_*lis 5 python pylint flask

我的 Python Flask 应用程序包含许多路由定义,例如

@app.route('/')
def index():
Run Code Online (Sandbox Code Playgroud)

然后pylint抱怨

W: 72, 4: Unused variable 'index' (unused-variable)
Run Code Online (Sandbox Code Playgroud)

这在技术上是正确的。我不能用 替换所有的函数名称_,因为 Flask 会抱怨

AssertionError: View function mapping is overwriting an existing endpoint function: _
Run Code Online (Sandbox Code Playgroud)

我可以用它们带有下划线前缀的等价物替换所有处理程序函数名称,即更改index_index等。是否有另一种处理这个问题的惯用方法?

Eri*_* L. 0

你有没有在 Pylint 上寻找 Flask 插件?我希望它可以帮助你,但这似乎可能对你有帮助(我说可能,因为我不使用 Flask,也没有遇到这个问题): https: //github.com/jschaf/ pylint-flask#usage

祝你好运,让我们知道你的结果