Skip to content
George - David Apostolidis edited this page Feb 3, 2023 · 1 revision

Service-based Assessment of Python Code Quality

This is a service that allows users to have their Python code directory reviewed and displays some analysis findings. You must set up your environment with a few of the tools provided here before you can begin using this service.

Pylint

Pylint is a static code analyser for Python 2 or 3. The latest version supports Python 3.7.2 and above.

Pylint analyses your code without actually running it. It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored. Pylint can infer actual values from your code using its internal code representation (astroid).

For command line use, pylint is installed with:

pip install pylint

It can also be integrated in most editors or IDEs. More information can be found in the documentation.

More info here: https://pylint.pycqa.org/en/latest/

Pytest

This plugin produces coverage reports. Compared to just using coverage run this plugin does some extras:

Subprocess support: you can fork or run stuff in a subprocess and will get covered without any fuss. Xdist support: you can use all of pytest-xdist’s features and still get coverage. Consistent pytest behavior. If you run coverage run -m pytest you will have slightly different sys.path (CWD will be in it, unlike when running pytest).

Install with pip:

pip install pytest-cov For distributed testing support install pytest-xdist:

pip install pytest-xdist

More info here: https://pytest-cov.readthedocs.io/en/latest/readme.html

Duplicate Code Detection Tool

A simple Python3 tool (also available as a GitHub Action) to detect similarities between files within a repository.

The following Python packages have to be installed:

nltk pip3 install --user nltk

gensim pip3 install --user gensim

astor pip3 install --user astor

punkt python3 -m nltk.downloader punkt

More info for how to use it here: https://github.com/platisd/duplicate-code-detection-tool#example

Pipreqs

Generate requirements.txt file for any project based on imports

Installation pip install pipreqs

Clone this wiki locally