简体   繁体   English

flake8 没有在用户目录中获取全局配置文件

[英]flake8 is not picking up global configuration file in user directory

I have flake8 installed in pipenv virtual environments on per project basis.我在每个项目的基础上在 pipenv 虚拟环境中安装了 flake8。

The flake8 docs state that: flake8 文档 state 指出:

Values set at the command line have highest priority, then those in the project configuration file, then those in your user directory, and finally there are the defaults.在命令行设置的值具有最高优先级,然后是项目配置文件中的值,然后是用户目录中的值,最后是默认值。

As per the docs I created two.flake8 files:根据我创建的文档 two.flake8 文件:

  1. In the project root - for per project configuration在项目根目录中 - 对于每个项目配置
  2. /Users/rusl/.config/flake8/.flake8 - for global configuration /Users/rusl/.config/flake8/.flake8 - 用于全局配置

When I run flake8 it picks up configuration options from a local file, but it completely ignores the global file.当我运行 flake8 时,它会从本地文件中获取配置选项,但它完全忽略了全局文件。

How can I make flake8 see the global configuration file so I don't have to repeat some configuration options in every project?如何让 flake8 看到全局配置文件,这样我就不必在每个项目中重复一些配置选项?

It can be a bit misleading, but the User Configuration section of the flake8 docs does mention a file :这可能有点误导,但 flake8 文档的用户配置部分确实提到了一个文件

Flake8 allows a user to use “global” configuration file to store preferences. Flake8 允许用户使用“全局”配置文件来存储首选项。

... ...

Note that Flake8 looks for ~\.flake8 on Windows and ~/.config/flake8 on Linux and other Unix systems.请注意, Flake8在 Windows 上查找~\.flake8 ,在 Linux 和其他 Unix 系统上查找~/.config/flake8

As answered in the comments , ~/.config/flake8 should be a file, not a directory.正如评论中所回答的那样~/.config/flake8应该是一个文件,而不是一个目录。

Note that as of flake8 4.0, flake8 no longer supports a global config file at all.请注意,从 flake8 4.0 开始, flake8 根本不再支持全局配置文件 I don't know what could motivate such a horrible idea, but that's where we are.我不知道是什么激发了这样一个可怕的想法,但这就是我们所处的位置。

Lots of docs are not up to date on this, so maybe this answer will help guide some people who think flake8 is ignoring their global config due to user error.很多文档都不是最新的,所以也许这个答案将有助于指导一些认为 flake8 由于用户错误而忽略其全局配置的人。 It's not you, it's them.不是你,是他们。

Anyone trying to get this running for flake8>=4.0.0 , that's because support for global config file is no longer present, see https://flake8.pycqa.org/en/latest/release-notes/4.0.0.html#backwards-incompatible-changes .任何试图让flake8>=4.0.0运行的人,这是因为不再支持全局配置文件,请参阅https://flake8.pycqa.org/en/latest/release-notes/4.0.0.html #backwards-incompatible-changes

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

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