Meta code analysis tool, bundling together multiple code analysis libraries
Project description
pynalyzer
Meta code analysis tool for Python, bundling together multiple code analysis libraries.
Table of Contents
About
The main idea behind pynalyzer is to improve and simplify
experience of python developers using multiple code analysis
tools at once.
pynalyzer provides easy to use Command Line Interface to
run all the code analysis checks you would ever need.
It is bundling together multiple cutting-edge code analysis libs for Python, specifically:
isortfor import sortingblackfor code formattingmypyfor typing checksbanditfor security issues
Advantages
pynalyzer is super simple to use with two easy to memorize commands: check and fix
pynalyzer is OS-independent, so you can use
it wherever you want:
- Windows / Linux / MacOS
- CMD / Powershell / Bash / zsh / others
It is also project-structure-independent, meaning you can use it in all types of Python projects:
- projects containing only
requirements.txtfor dependencies - projects using
setup.pyfor dependencies and/or packaging - project using
pyproject.tomlfor dependencies and/or packaging - etc.
Easily configurable with industry standard - pyproject.toml file
It can be used in CI/CD, to prevent false positive checks between local and remote runs.
Freedom of configuration - you decide how you want to configure every static code analysis tool,
that pynalyzer bundles (e.g. mypy) by configuring them through pyproject.toml file.
CI/CD
The main use-case for pynalyzer is to run all code analysis checks
with single command locally, but it can also be used to simplify
CI/CD pipelines like GitHub Actions Workflow, GitLab Pipelines, Jenkins, etc.
Using pynalyzer in CI/CD has one huge advantage,
you won't face a problem where checks pass locally,
but fail on a remote, which is a pretty popular scenario,
when using standalone commands.
This is not the case in pynalyzer, as it will use the
same commands and the same configuration file to configure
code analysis tools, both on remote and locally.
Installation
Install using pip:
pip install pynalyzer
or using poetry:
poetry add pynalyzer
Prerequisites
In order to successfully run pynalyzer, you need to:
-
Create
pyproject.tomlfile in root directory of the project (if it doesn't already exist) -
Configure
pynalyzer, by adding[tool.pynalyzer]section topyproject.tomlfile -
Under
[tool.pynalyzer]section specify thepathskey with value being an array of strings, which holds all paths that need to be checked by pynalyzer code analysis checks.Example
[tool.pynalyzer] paths = ["tests", "scripts/my_script.py"]
Note
- paths can be absolute or relative to project root directory
- paths can lead to single file or to directory with files
-
Configure static analysis tools in
pyproject.tomlfile to suit your likings
Tools configuration
All code analysis tools are configured through pyproject.toml file,
which you need to put at the root of your project.
For the instruction of how to configure each tool
using pyproject.toml check their docs:
Minimal configuration example:
[tool.black]
line-length = 88
target-version = ["py37"]
[tool.isort]
profile = "black"
[tool.mypy]
disallow_untyped_defs = true
[tool.bandit.assert_used]
skips = ["*_test.py", "*/test_*.py"]
[tool.pynalyzer]
paths = ["some_dir", "some_file.py"] # Fill this with paths to dirs and files you want to analyze
Note
- Other configuration files than
pyproject.toml, e.g..banditwill not be taken into account when runningpynalyzer. Configuration for every code analysis tool will only be taken frompyproject.toml.pynalyzeris not configuring / forcing any configuration of any tool.
This approach gives you freedom of configuration, you can configure every tool to suit your preferences and needs.
Usage
Make sure you have done all the steps in Prerequisites before running pynalyzer
Running static code analysis checks locally
To run all static code analysis checks:
- Go to project root directory (where you created
pyproject.tomlfile) - Execute
checkcommand (without any arguments):check
This will run all the code analysis checks at once on all files
and directories, one provided inpathsinpyproject.tomlconfiguration file.
Note
To not waste any time and / or resources, this command will not continue to run other checks, if one of them failed.For example, if 2nd check (e.g.
isort) failed, then 3rd and 4th checks won't execute.
Developer should firstly fix the issues that caused the 2nd check to fail, in order to continue checking code with checks 3rd and 4th.This is done this way to be easy to use with CI/CD, where every minute is precious using paid runners.
Automatically fixing code analysis issues
Some code analysis issues can be automatically fixed:
- code formatting (
black) - import sorting (
isort)
To run all fixes at once, one can use fix command:
- Go to project root directory (where you created
pyproject.tomlfile) - Execute
fixcommand (without any arguments):fix
Credits
Image used for logo was downloaded from: Binary icons created by Freepik - Flaticon
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynalyzer-1.0.0.tar.gz.
File metadata
- Download URL: pynalyzer-1.0.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/6.3.8-100.fc37.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ecc3e1f556500ee85e10a9be965fda174734a7e9dce573d70d2f332e9699eb8
|
|
| MD5 |
04a78e34b539969956006db1f84abb4f
|
|
| BLAKE2b-256 |
601ab024f1c58e297f52d6acd7174e6db777a82f88e7dfc783ebbf7020880f2a
|
File details
Details for the file pynalyzer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pynalyzer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/6.3.8-100.fc37.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89dfde2cffa73dadb919c81d8760db1c3cbef5293778478c8f7e3788ad105b7e
|
|
| MD5 |
da299768f56299c8e7a088f7ec62b0db
|
|
| BLAKE2b-256 |
e66bbc227ee453c93e7bb1651fce70d14dc19da5718fa4ddb0bfd409e639b335
|