Skip to content

flake8的使用

安装

pip install flake8

conda install flake8

依赖的库

$ pip show flake8 | grep Requires
Requires: mccabe, pycodestyle, pyflakes
  • mccabe: 计算单元代码的McCabe指数
  • pycodestyle: 代码风格检查
  • pyflakes: 代码格式检查

配置

# FastAPI的设置: https://github.com/tiangolo/fastapi/blob/master/.flake8
[flake8]
max-line-length = 88
select = C,E,F,W,B,B9
ignore = E203, E501, W503
exclude = __init__.py

🔗选项一览

📢注意: 命令行参数的优先级大于配置文件

VSCode中启用.flake8

```json { "python.linting.enabled": true, "python.linting.flake8Enabled": true, "python.linting.flake8Args": [ "--config=.flake8" ], }