简体   繁体   中英

Configuring flake8 on macOS/OSX

I'm trying to change the line length for flake8 (version 3.7.7) on OSX (10.14.5), so that it matches the line length used in Black (the Python auto formatter). I'm using Sublimetext 3 with the SublimeLinter-flake8 plugin.

What I've tried to do is create a folder ~/.config/flake8 and then placed a file in it with the settings:

[flake8]
max-line-length = 88

I have called this file config.flake8. In addition, I've tried naming it 'flake8', 'flake8.rc', placing it in both ~/.config and ~/.config/flake8.

However, this hasn't worked. I get

./lorenz.py:13:80: E501 line too long (81 > 79 characters)

both when I run flake8 in the terminal (so this is not an ST3 problem) and when I have the code open on Sublimetext3.

I've looked at the documentation for flake8 and haven't really been able to get much out of it.

Can anyone let me know where I'm going wrong?

Instead of putting a file into the directory ~/.config/flake8 , the name of the file should be flake8 and it should be placed in the ~/.config directory:

For example with the config in the following location:

$ cat ~/.config/flake8 
[flake8]
max-line-length = 88

I can now see that flake8 gives warnings about 88 line length lines:

$ python3 -m flake8 
./pinpoint-poc-db-listener.py:17:89: E501 line too long (96 > 88 characters)
./pinpoint-poc-db-listener.py:18:89: E501 line too long (248 > 88 characters)

Reference: https://flake8.pycqa.org/en/latest/user/configuration.html

Does it have to be a system-wide configuration, or could it be just for that one project? If the latter applies, you could try saving it to a file called .flake8 in your project's root folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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