简体   繁体   English

如果未安装插件,如何使 flake8 失败?

[英]How to make flake8 fail if a plugin is not installed?

I use flake8 + flake8-docstrings for enforcing the style guide in one of my projects.我使用flake8 + flake8-docstrings在我的一个项目中强制执行样式指南。 My pre-commit git hook has this line in it, so that it fails if flake8 finds something:我的pre-commit git 钩子中有这一行,因此如果flake8发现某些内容,它将失败:

flake8 --config=setup.cfg ./ || exit 1

But if my code has errors in docstring formatting and flake8-docstrings is not installed, this hook silently passes, even if I specify --select=flake8-docstrings or --select=non-existing-plugin .但是,如果我的代码在 docstring 格式中存在错误并且未安装flake8-docstrings ,则即使我指定--select=flake8-docstrings--select=non-existing-plugin ,此钩子也会静默通过。

I've read --help , man , online docs and Google, it looks like such functionality doesn't exist.我读过--helpman 、在线文档和谷歌,看起来这样的功能不存在。

Am I correct?我对么? Should I post a feature request?我应该发布功能请求吗? Does it make sense to add cludges to my pre-commit script, such as grep ing flake8 --help for flake8-docstrings ?在我的pre-commit脚本中添加 cluds 是否有意义,例如grep ing flake8 --help for flake8-docstrings

currently there is no such feature -- but in flake8 5.x (the next released version) there will be a (name pending) --require-plugins option目前没有这样的功能——但在 flake8 5.x(下一个发布版本)中会有一个(名称待定) --require-plugins选项

your best bet at the moment is to either (1) search pip freeze for flake8-docstrings (2) search flake8's --version output for flake8-docstrings您目前最好的选择是 (1) 搜索pip freeze以获取flake8-docstrings (2) 搜索 flake8 的--version output 以获取flake8-docstrings

$ pip freeze | grep flake8-docstrings
flake8-docstrings==1.6.0
$ flake8 --version | grep flake8-docstrings
4.0.1 (flake8-docstrings: 1.6.0, pydocstyle: 6.1.1, mccabe: 0.6.1,

disclaimer: I'm the current flake8 maintainer免责声明:我是当前的 flake8 维护者

I've ended up using flake8 --version | grep -q 'flake8-docstrings' || exit 1我最终使用了flake8 --version | grep -q 'flake8-docstrings' || exit 1 flake8 --version | grep -q 'flake8-docstrings' || exit 1 flake8 --version | grep -q 'flake8-docstrings' || exit 1 for now. flake8 --version | grep -q 'flake8-docstrings' || exit 1

Also, I've discovered an existing feature request #283 .另外,我发现了一个现有的功能请求#283 Readers will probably find future news there.读者可能会在那里找到未来的新闻。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM