Tool to check code style

Library to use

pycodestyle

Features Plugin architecture: Adding new checks is easy. Parseable output: Jump to error location in your editor. Small: Just one Python file, requires only stdlib. You can use just the pycodestyle.py file for this purpose. Comes with a comprehensive test suite.

flake8

Flake8 is a wrapper around these tools: PyFlakes pycodestyle Ned Batchelder’s McCabe script

pylint

Pylint is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring

Code to check

qiita.py


import pycodestyle
import flake8
import pylint


import os
x = {"adfasd"       , 'adsfasdfasd'}
y         =1

pycodestyle

NEW1.py:6:20: E203 whitespace before ','
NEW1.py:7:2: E221 multiple spaces before operator
NEW1.py:7:12: E225 missing whitespace around operator
NEW1.py:8:1: W391 blank line at end of file

flake8


NEW1.py:1:1: F401 'pycodestyle' imported but unused
NEW1.py:2:1: F401 'flake8' imported but unused
NEW1.py:3:1: F401 'pylint' imported but unused
NEW1.py:5:1: F401 'os' imported but unused
NEW1.py:6:20: E203 whitespace before ','
NEW1.py:7:2: E221 multiple spaces before operator
NEW1.py:7:12: E225 missing whitespace around operator
NEW1.py:8:1: W391 blank line at end of file

pylint

************* Module newww.NEW1
NEW1.py:6:20: C0326: No space allowed before comma
x = {"adfasd"       , 'adsfasdfasd'}
                    ^ (bad-whitespace)
NEW1.py:7:10: C0326: Exactly one space required around assignment
y         =1
          ^ (bad-whitespace)
NEW1.py:8:0: C0305: Trailing newlines (trailing-newlines)
NEW1.py:1:0: C0103: Module name "NEW1" doesn't conform to snake_case naming style (invalid-name)
NEW1.py:1:0: C0114: Missing module docstring (missing-module-docstring)
NEW1.py:6:0: C0103: Constant name "x" doesn't conform to UPPER_CASE naming style (invalid-name)
NEW1.py:7:0: C0103: Constant name "y" doesn't conform to UPPER_CASE naming style (invalid-name)
NEW1.py:1:0: W0611: Unused import pycodestyle (unused-import)
NEW1.py:2:0: W0611: Unused import flake8 (unused-import)
NEW1.py:3:0: W0611: Unused import pylint (unused-import)
NEW1.py:5:0: W0611: Unused import os (unused-import)
NEW1.py:5:0: C0411: standard import "import os" should be placed before "import pycodestyle" (wrong-import-order)

-------------------------------------
Your code has been rated at -10.00/10


Summary

Severity pylint > flake8 > pycodestyle

Recommended Posts

Tool to check code style
Rewrite Python2 code to Python3 (2to3)
I want to write in Python! (1) Code format check
Test code to check for broken links in the page
Part 1 Attempt to code mathematics (∈)
Command to generate QR code
Source code character code check script
Set VS Code to PyCharm.
Create a tool to check scraping rules (robots.txt) in Python
Check the code with flake8
Regular expression check tool summary
Convert python 3.x code to python 2.x
Code Python to check and graph if it follows Benford's law
[AWS] EBS creation status check tool
C code review tool using pycparser
Code to randomly generate a score
Added code snippet functionality to django-ckeditor
To maintain code quality in PyCharm
Check python code styles using pep8
Linux commands related to character code
How to check Linux OS version
How to run TensorFlow 1.0 code in 2.0
Migrate from VS Code to PyCharm
A tool to convert Juniper config
pynq-z1 From purchase to operation check
10 questions to check before web scraping
I made a tool to convert Jupyter py to ipynb with VS Code
I want to format and check Python code to my liking on VS Code