flake8规范

一.概述
flake8(代码规范利器)是下面三个工具的封装:
1)PyFlakes
2)Pep8
3)NedBatchelder’s McCabe script

二.安装

pip install flake8

三.使用

(rd) ➜  web git:(develop) ✗ flake8 views.py   # 检查一个文件
views.py:1:1: E265 block comment should start with '# '
views.py:23:80: E501 line too long (117 > 79 characters)
views.py:56:32: E261 at least two spaces before inline comment
views.py:56:32: E262 inline comment should start with '# '
views.py:62:32: E265 block comment should start with '# '
views.py:63:32: E265 block comment should start with '# '
views.py:82:80: E501 line too long (82 > 79 characters)
views.py:100:39: E251 unexpected spaces around keyword / parameter equals
views.py:111:65: E231 missing whitespace after ':'
views.py:111:80: E501 line too long (113 > 79 characters)
views.py:123:80: E501 line too long (96 > 79 characters)


(rd) ➜  web git:(develop) ✗ flake8  # 检查一个项目的所有文件
./common.py:16:23: F841 local variable 'e' is assigned to but never used
./settings.py:12:1: F401 'src.conf.GlobalConf.UPLOAD_PATH' imported but unused
./settings.py:12:1: F401 'src.conf.GlobalConf.LOGIN_URL' imported but unused
./settings.py:89:80: E501 line too long (80 > 79 characters)
./settings.py:131:80: E501 line too long (96 > 79 characters)
./settings.py:146:80: E501 line too long (81 > 79 characters)
./settings.py:186:80: E501 line too long (88 > 79 characters)
./settings.py:223:80: E501 line too long (93 > 79 characters)
./urls.py:25:80: E501 line too long (80 > 79 characters)
./urls.py:29:80: E501 line too long (90 > 79 characters)
./urls.py:32:23: E124 closing bracket does not match visual indentation

你可能感兴趣的:(工具)