19
loading...
This website collects cookies to deliver better user experience
pylint
is a static code analysis tool that lists error which may come after execution of the python code, helps to enforce a coding standard, and look for code smells, offers simple refactoring suggestions, and other suggestions about code complexity.pylint
has been around for 13 years, and it is still constantly maintained. Though it is pedantic out of the box, it is fully customizable through a .pylintrc
file that you can customize for errors or agreements relevant to you.a = 23
b = 45
c = a + b
print(c)
pylint
you'll get the following output that lists down multiple styling issues in the program.% pylint sample.py
************* Module sample
sample.py:5:0: C0304: Final newline missing (missing-final-newline)
sample.py:1:0: C0114: Missing module docstring (missing-module-docstring)
sample.py:1:0: C0103: Constant name "a" doesn't conform to UPPER_CASE naming style (invalid-name)
sample.py:2:0: C0103: Constant name "b" doesn't conform to UPPER_CASE naming style (invalid-name)
sample.py:3:0: C0103: Constant name "c" doesn't conform to UPPER_CASE naming style (invalid-name)
pyflakes
is a verification tool for python source code. It just doesn't verify the style at all but verifies only logistic errors. It emits very few false positives, which means that it will not display errors about missing docstrings or argument names that don't match the naming style.pyflakes
faster than pylint
is its ability to examine the AST of each file individually, combined with a limited set of errors.pyflakes
with$ pip install --upgrade pyflakes
pyflakes
don’t do any stylistic checks, but if you want, you can do style checks using another tool called Flake8
that combines pyflakes
with PEP8
style checks. Additionally, Flake8
also gives you the advantage of adding configuration options for each project.mypy
is slightly different from pylint
and pyflakes
as it is a static type checker for Python. It requires your code to be annotated using Python 3 function annotation syntax (PEP484) in order to type-check the code and detect common bugs. The purpose of mypy
is to combine the advantages of dynamic and static typing (using a typing module).def fib(n):
a, b = 0, 1
while a < n:
yield a
a, b = b, a+b
def fib(n: int) -> Iterator[int]:
a, b = 0, 1
while a < n:
yield a
a, b = b, a+b
pylint
, pep8
or pyflakes
and provide only what is important.