АЄОА: не завжди заради маленького проекту (на кшталт скрипта) хочеться запускати громізке середовище розробки, та тут нам на допомогу приходить pycodestyle - невеличка консольна утилітка, яка перевіряє наш код на відповідність усім правилам.
$ pycodestyle db.py
db.py:34:80: E501 line too long (93 > 79 characters)
db.py:36:80: E501 line too long (98 > 79 characters)
db.py:62:80: E501 line too long (81 > 79 characters)
db.py:66:80: E501 line too long (129 > 79 characters)
db.py:82:80: E501 line too long (84 > 79 characters)
db.py:114:80: E501 line too long (80 > 79 characters)
db.py:115:1: W391 blank line at end of file
Можна зробити вивід трішки інформативнішим (показувати рядок коду з помилкою, цитату з PEP8 і статистику по усіх помилках):
$ pycodestyle --show-source --show-pep8 --statistics db.py
db.py:34:80: E501 line too long (93 > 79 characters)
[f'"{fname}" {ftype} {fmody}' for fname, ftype, fmody in fields_tuple] + ref_list
^
Limit all lines to a maximum of 79 characters.
There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to have
several windows side-by-side. The default wrapping on such devices looks
ugly. Therefore, please limit all lines to a maximum of 79 characters.
For flowing long blocks of text (docstrings or comments), limiting the
length to 72 characters is recommended.
Reports error E501.
...
db.py:115:1: W391 blank line at end of file
^
Trailing blank lines are superfluous.
Okay: spam(1)
W391: spam(1)\n
However the last line should end with a new line (warning W292).
6 E501 line too long (93 > 79 characters)
1 W391 blank line at end of file
А для найлінивіших людей існує веб-сервіс: http://pep8online.com
Коментарі
Дописати коментар