【问题标题】:How to exclude files in git pre-commit hook with flake8?如何使用 flake8 排除 git pre-commit 钩子中的文件?
【发布时间】:2014-02-06 22:31:21
【问题描述】:

这是我目前拥有的:

sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT, ignore='W801,E128,E501,W402,F403'))

但它抱怨 django south 迁移文件,所以我想排除迁移文件,我的直接猜测是:

sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT, ignore='W801,E128,E501,W402,F403', exclude='migrations'))

但收到此错误:

TypeError: git_hook() got an unexpected keyword argument 'exclude'

查看源代码没有这样的参数供我使用...

def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):

有没有办法让我排除一些文件?

【问题讨论】:

    标签: flake8


    【解决方案1】:

    我所要做的就是在 ~/.config/flake8 中创建配置文件:

    http://flake8.readthedocs.org/en/latest/config.html

    或在项目级别创建 tox.ini

    【讨论】:

    • 不幸的是,tox.ini 对 3.5.0 没有帮助,尽管这些错误报告标记为已修复:gitlab.com/pycqa/flake8/issues/218 并且用户配置不允许按项目配置。可以用 3.5.0 验证吗?
    猜你喜欢
    • 2019-06-18
    • 2014-02-15
    • 2014-06-27
    • 2017-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    相关资源
    最近更新 更多