Pylint, install this Python code analysis tool on Ubuntu 20.04

about pylint

In the next article we are going to take a look at PyLint. This tool adds an additional layer to help the developer have clean and error-free Python code. Is about a Python static code analysis tool that looks for bugs, helps enforce a coding standard and offers simple refactoring suggestions.

This tool is highly configurable through an extensive configuration file. It offers possibilities to handle errors and warnings from within the code. Also It will give us the possibility to write our own plugins to add our own controls or to extend pylint in one way or another.

One of the great advantages of using PyLint is that it is open source and free. This will give developers the ability to include it in a wide variety of projects. What's more, seamlessly integrates with many popular IDEs so that we can use it without any problem. It can also be used as a standalone application.

PyLint General Features

Some of the main features are:

  • It has error detection so that users can further refine the code we write.
  • Es fully customizable. The main configuration is in a text file that you can configure to your liking.
  • Pylint can be integrated into various IDEs such as: Spyder, Editra, TextMate, Eclipse with PyDev, etc.
  • Refactoring help, detect duplicate code.
  • PyLint for your analysis uses Python PEP8, so we are talking about almost a standard in development with this language.
  • This tool is installed with Pyreverse, with which we can create UML diagrams for Python code.
  • The execution of Pylint in the code of our projects can be automated using Apycot, Hudson or Jenkins.

These are just some of the features of this project. They can consult all of them in detail from your web page.

Install PyLint on Ubuntu 20.04

Using APT

As indicated in the installation section from the web page of this project, Ubuntu users can open a terminal (Ctrl + Alt + T) and run the following command in it to install PyLint:

install pylint with apt

sudo apt install pylint

The above command will install this tool. Then we can check the installed version with the command:

pytlint apt version

pylint --version

Using PIP

Users can also use the PIP package manager to install PyLint. Installation is quite simple. To start we will only have to open a terminal (Ctrl + Alt + T) and update our system packages.

sudo apt update; sudo apt upgrade

Now we will install PIP. If you still do not have it installed on your system, in the terminal it will only be necessary to write:

pip installation 3

sudo apt install python3-pip python3-dev

Once the installation is complete, we can check installed version of PIP with the command:

installed version of pip3

pip3 --version

At this point, we can proceed to install PyLint. In the same terminal we only need to write:

install pylint with pip3

pip3 install pylint

This will install this tool. Now for check the installed version we can use this other command:

pylint version with pip3

python3 -m pylint --version

A quick look at PyLint

The program has a very simple terminal interface that allows us to use it without problems. The basic usage would be as follows:

pylint [opciones] módulos_o_paquetes

As well Python files can be parsed. The basic command to use would be something like:

pylint mimodulo.py

As indicated in the documentation, it is also possible to call Pylint from another python program:

import pylint.lint
pylint_opts = ['--version']]
pylint.lint.Run(pylint_opts)

In this way, we will be able to analyze our code, and using the screen output we will be able to notice the necessary changes. An example of what the screen output of the above code looks like would be the following:

pylint mymodule

Once it shows us the errors, we will have to update our code and fix what is necessary.

In these lines we have just seen a very useful tool for code development with Python, which we can take advantage of quickly and easily by installing it. For more information about this tool, its installation and its use, users can consult the project documentation.


Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.