git 每个项目 flake8 最大线长?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42325453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Per-project flake8 max line length?
提问by d33tah
I'm using a Flake8 git hook in my project and I want to relax the line length limit, but only for one project. Given that it looks like there's no clear API for that, how do I modify this hook to do that? Alternatively, is there a git-config setting or an environment variable that would let me set that? Here's the hook source code:
我在我的项目中使用了 Flake8 git hook,我想放宽行长限制,但仅限于一个项目。鉴于看起来没有明确的 API,我该如何修改这个钩子来做到这一点?或者,是否有 git-config 设置或环境变量可以让我设置?这是钩子源代码:
#!/usr/bin/env python
import os
import sys
import logging
import os.path as P
from flake8.main import git
if __name__ == '__main__':
ret = git.hook(
strict=git.config_for('strict'),
lazy=git.config_for('lazy'),
)
if ret:
sys.exit(ret)
回答by Matthieu Moy
Use the setup.cfg
file in each project. This file is read by various Python-related tools, including pep8 (see pep8's documentation) and flake8.
setup.cfg
在每个项目中使用该文件。该文件由各种 Python 相关工具读取,包括 pep8(参见pep8 的文档)和 flake8。
The documentation for setup.cfg
with flake8
is in the Configuring Flake8chapter.
setup.cfg
with的文档flake8
在配置 Flake8章节中。
In short, you want a setup.cfg
file with this content (obviously, adjust the 99 to your needs):
简而言之,您需要一个setup.cfg
包含此内容的文件(显然,根据您的需要调整 99):
[flake8]
max-line-length = 99