简体   繁体   English

我在哪里放置 flake8 在 Windows 上的配置文件?

[英]Where do i put the config file for flake8 on Windows?

I installed flake8 to do some work from home on my windows machine, but don't know where to put my configuration file.我安装了 flake8 以便在我的 Windows 机器上在家做一些工作,但不知道将我的配置文件放在哪里。

The documentation states, that the flake8 file has to be put in ~/.config/flake8 .文档指出, flake8文件必须放在~/.config/flake8

I tried %USERPROFILE%/.config/flake8 and simply %USERPROFILE%/flake8 both to no avail.我试过%USERPROFILE%/.config/flake8%USERPROFILE%/flake8都无济于事。 Perhaps, anyone with experience with working with flake8 on Windows can answer this?也许,任何有在 Windows 上使用 flake8 经验的人都可以回答这个问题?

If you open up the source code for flake8 (main.py), you will see that on Windows, the default config path is significantly different than it is on Linux:如果你打开 flake8 (main.py) 的源代码,你会看到在 Windows 上,默认配置路径与在 Linux 上有很大不同:

if sys.platform.startswith('win'):
    DEFAULT_CONFIG = os.path.expanduser(r'~\.flake8')

On my Windows 7 machine, that resolves to: C:\\Users\\username\\.flake8在我的 Windows 7 机器上,解析为: C:\\Users\\username\\.flake8

So you'll have to create a file called .flake8 .所以你必须创建一个名为.flake8的文件。 Be sure it begins with a period.确保它以句点开头。 I did that by opening up the command line and going to my home folder and executing the following command:我通过打开命令行并转到我的主文件夹并执行以下命令来做到这一点:

NUL > .flake8

That created the blank file as you can't create it in Explorer (or I couldn't anyway).这创建了空白文件,因为您无法在资源管理器中创建它(或者我也不能)。 Once that's created, you can open it and add whatever you like to it.创建后,您可以打开它并添加任何您喜欢的内容。

UPDATE - I finally found some "documentation" that mentions Windows here:更新- 我终于找到了一些提到 Windows 的“文档”:

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

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