<p align="center">
<img alt="Logo" src="assets/img/binary-code.png" />
</p>
<h2 align="center">pynalyzer</h2>
<h4 align="center">Meta code analysis tool for Python,
bundling together multiple code analysis libraries. </h4>
<hr></hr>
<p align="center">
<a href="https://docs.python.org/"><img alt="python" src="https://img.shields.io/badge/Python-3.7+-3776ab?style=flat-square&logo=python&labelColor=dddddd"></a>
<a href="https://pypi.org/project/pynalyzer/"><img alt="pypi" src="https://img.shields.io/pypi/dm/pynalyzer?style=flat-square&logo=pypi&label=pypi%20downloads&labelColor=dddddd&color=3776ab"></a>
<a href="https://python-poetry.org/docs/"><img alt="poetry" src="https://img.shields.io/badge/dependencies-poetry-60a5fa?style=flat-square&logo=poetry&labelColor=dddddd"></a>
<a href="https://docs.pytest.org/"><img alt="pytest" src="https://img.shields.io/badge/tests-pytest-0a9edc?style=flat-square&logo=pytest&labelColor=dddddd"></a>
<a href="https://black.readthedocs.io/en/stable/"><img alt="black" src="https://img.shields.io/badge/code%20style-black-000000?style=flat-square&logoColor=000000&labelColor=dddddd"></a>
<a href="https://pycqa.github.io/isort/"><img alt="isort" src="https://img.shields.io/badge/imports-isort-ef8336?style=flat-square&labelColor=dddddd"></a>
<a href="https://mypy.readthedocs.io/en/stable/"><img alt="mypy" src="https://img.shields.io/badge/type%20checker-mypy-1f5082?style=flat-square&labelColor=dddddd"></a>
<a href="https://bandit.readthedocs.io/en/latest/"><img alt="bandit" src="https://img.shields.io/badge/security-bandit-fad23f?style=flat-square&labelColor=dddddd"></a>
</p>
## Table of Contents
<!-- TOC -->
* [Table of Contents](#table-of-contents)
* [About](#about)
* [Advantages](#advantages)
* [CI/CD](#cicd)
* [Installation](#installation)
* [Prerequisites](#prerequisites)
* [Tools configuration](#tools-configuration)
* [Usage](#usage)
* [Running static code analysis checks locally](#running-static-code-analysis-checks-locally)
* [Automatically fixing code analysis issues](#automatically-fixing-code-analysis-issues)
* [Credits](#credits)
<!-- TOC -->
## 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:
- [`isort`](https://pycqa.github.io/isort/) for import sorting
- [`black`](https://black.readthedocs.io/en/stable/) for code formatting
- [`mypy`](https://mypy.readthedocs.io/en/stable/) for typing checks
- [`bandit`](https://bandit.readthedocs.io/en/latest/) for 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.txt` for dependencies
- projects using `setup.py` for dependencies and/or packaging
- project using `pyproject.toml` for 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`](https://pip.pypa.io/en/stable/):
```shell
pip install pynalyzer
```
or using [`poetry`](https://python-poetry.org/):
```shell
poetry add pynalyzer
```
## Prerequisites
In order to successfully run `pynalyzer`, you need to:
1. [Install `pynalyzer` package](#installation)
2. Create `pyproject.toml` file in root directory of the project (if it doesn't already exist)
3. Configure `pynalyzer`, by adding `[tool.pynalyzer]` section to `pyproject.toml` file
4. Under `[tool.pynalyzer]` section specify the `paths` key with value being an array of strings,
which holds all paths that need to be checked by pynalyzer code analysis checks.
*Example*
```toml
[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
5. [Configure static analysis tools in `pyproject.toml` file to suit your likings](#tools-configuration)
### 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:
- [isort](https://pycqa.github.io/isort/docs/configuration/options.html)
- [black](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file)
- [mypy](https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file)
- [bandit](https://bandit.readthedocs.io/en/latest/config.html#bandit-settings)
Minimal configuration example:
```toml
[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**
> 1. Other configuration files than `pyproject.toml`, e.g. `.bandit` will **not** be
> taken into account when running `pynalyzer`.
> Configuration for every code analysis tool will only be taken from `pyproject.toml`.
> 2. `pynalyzer` is 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](#prerequisites) before running `pynalyzer`
### Running static code analysis checks locally
To run all static code analysis checks:
1. Go to project root directory (where you created `pyproject.toml` file)
2. Execute `check` command (without any arguments):
```shell
check
```
This will run all the code analysis checks at once on all files
and directories, one provided in `paths` in `pyproject.toml` configuration 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:
1. Go to project root directory (where you created `pyproject.toml` file)
2. Execute `fix` command (without any arguments):
```shell
fix
```
## Credits
Image used for logo was downloaded from: <a href="https://www.flaticon.com/free-icons/binary" title="binary icons">Binary icons created by Freepik - Flaticon</a>
Raw data
{
"_id": null,
"home_page": "https://github.com/Devourian/pynalyzer",
"name": "pynalyzer",
"maintainer": "Devourian",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "dorian.antonkiewicz@gmail.com",
"keywords": "automation,code_quality,static_code_analysis,code_analysis,black,mypy,isort,bandit,cicd",
"author": "Devourian",
"author_email": "dorian.antonkiewicz@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/60/1a/b024f1c58e297f52d6acd7174e6db777a82f88e7dfc783ebbf7020880f2a/pynalyzer-1.0.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <img alt=\"Logo\" src=\"assets/img/binary-code.png\" />\n</p>\n\n<h2 align=\"center\">pynalyzer</h2>\n<h4 align=\"center\">Meta code analysis tool for Python, \nbundling together multiple code analysis libraries. </h4>\n<hr></hr>\n<p align=\"center\">\n<a href=\"https://docs.python.org/\"><img alt=\"python\" src=\"https://img.shields.io/badge/Python-3.7+-3776ab?style=flat-square&logo=python&labelColor=dddddd\"></a>\n<a href=\"https://pypi.org/project/pynalyzer/\"><img alt=\"pypi\" src=\"https://img.shields.io/pypi/dm/pynalyzer?style=flat-square&logo=pypi&label=pypi%20downloads&labelColor=dddddd&color=3776ab\"></a>\n<a href=\"https://python-poetry.org/docs/\"><img alt=\"poetry\" src=\"https://img.shields.io/badge/dependencies-poetry-60a5fa?style=flat-square&logo=poetry&labelColor=dddddd\"></a>\n<a href=\"https://docs.pytest.org/\"><img alt=\"pytest\" src=\"https://img.shields.io/badge/tests-pytest-0a9edc?style=flat-square&logo=pytest&labelColor=dddddd\"></a>\n<a href=\"https://black.readthedocs.io/en/stable/\"><img alt=\"black\" src=\"https://img.shields.io/badge/code%20style-black-000000?style=flat-square&logoColor=000000&labelColor=dddddd\"></a>\n<a href=\"https://pycqa.github.io/isort/\"><img alt=\"isort\" src=\"https://img.shields.io/badge/imports-isort-ef8336?style=flat-square&labelColor=dddddd\"></a>\n<a href=\"https://mypy.readthedocs.io/en/stable/\"><img alt=\"mypy\" src=\"https://img.shields.io/badge/type%20checker-mypy-1f5082?style=flat-square&labelColor=dddddd\"></a>\n<a href=\"https://bandit.readthedocs.io/en/latest/\"><img alt=\"bandit\" src=\"https://img.shields.io/badge/security-bandit-fad23f?style=flat-square&labelColor=dddddd\"></a>\n</p>\n\n\n## Table of Contents\n\n<!-- TOC -->\n * [Table of Contents](#table-of-contents)\n * [About](#about)\n * [Advantages](#advantages)\n * [CI/CD](#cicd)\n * [Installation](#installation)\n * [Prerequisites](#prerequisites)\n * [Tools configuration](#tools-configuration)\n * [Usage](#usage)\n * [Running static code analysis checks locally](#running-static-code-analysis-checks-locally)\n * [Automatically fixing code analysis issues](#automatically-fixing-code-analysis-issues)\n * [Credits](#credits)\n<!-- TOC -->\n\n\n## About\n\nThe main idea behind `pynalyzer` is to improve and simplify \nexperience of python developers using multiple code analysis \ntools at once.\n \n`pynalyzer` provides easy to use Command Line Interface to\nrun all the code analysis checks you would ever need.\n\nIt is bundling together multiple cutting-edge \ncode analysis libs for Python, specifically:\n- [`isort`](https://pycqa.github.io/isort/) for import sorting\n- [`black`](https://black.readthedocs.io/en/stable/) for code formatting\n- [`mypy`](https://mypy.readthedocs.io/en/stable/) for typing checks\n- [`bandit`](https://bandit.readthedocs.io/en/latest/) for security issues\n\n\n### Advantages\n\n`pynalyzer` is super simple to use with two easy to memorize commands: `check` and `fix`\n\n`pynalyzer` is **OS-independent**, so you can use \nit wherever you want:\n- Windows / Linux / MacOS\n- CMD / Powershell / Bash / zsh / others\n\nIt is also **project-structure-independent**, meaning \nyou can use it in all types of Python projects:\n- projects containing only `requirements.txt` for dependencies\n- projects using `setup.py` for dependencies and/or packaging\n- project using `pyproject.toml` for dependencies and/or packaging\n- etc.\n\nEasily configurable with industry standard - `pyproject.toml` file\n\nIt can be used in CI/CD, to prevent false positive checks between local and remote runs.\n\nFreedom of configuration - you decide how you want to configure every static code analysis tool,\nthat `pynalyzer` bundles (e.g. `mypy`) by configuring them through `pyproject.toml` file.\n\n\n### CI/CD\n \nThe main use-case for `pynalyzer` is to run all code analysis checks \nwith single command locally, but it can also be used to simplify \nCI/CD pipelines like GitHub Actions Workflow, GitLab Pipelines, Jenkins, etc.\n\nUsing `pynalyzer` in CI/CD has one huge advantage,\nyou won't face a problem where checks pass locally, \nbut fail on a remote, which is a pretty popular scenario,\nwhen using standalone commands.\n\nThis is not the case in `pynalyzer`, as it will use the \nsame commands and the same configuration file to configure\ncode analysis tools, both on remote and locally.\n\n\n## Installation\n\nInstall using [`pip`](https://pip.pypa.io/en/stable/):\n```shell\npip install pynalyzer\n```\nor using [`poetry`](https://python-poetry.org/):\n```shell\npoetry add pynalyzer\n```\n\n\n## Prerequisites\n\nIn order to successfully run `pynalyzer`, you need to:\n1. [Install `pynalyzer` package](#installation)\n2. Create `pyproject.toml` file in root directory of the project (if it doesn't already exist)\n3. Configure `pynalyzer`, by adding `[tool.pynalyzer]` section to `pyproject.toml` file\n4. Under `[tool.pynalyzer]` section specify the `paths` key with value being an array of strings,\nwhich holds all paths that need to be checked by pynalyzer code analysis checks.\n \n *Example*\n ```toml\n [tool.pynalyzer]\n paths = [\"tests\", \"scripts/my_script.py\"]\n ```\n > **Note** \n > - paths can be absolute or relative to project root directory\n > - paths can lead to single file or to directory with files\n5. [Configure static analysis tools in `pyproject.toml` file to suit your likings](#tools-configuration)\n\n\n### Tools configuration\n\nAll code analysis tools are configured through `pyproject.toml` file,\nwhich you need to put at the root of your project.\n \nFor the instruction of how to configure each tool\nusing `pyproject.toml` check their docs:\n- [isort](https://pycqa.github.io/isort/docs/configuration/options.html)\n- [black](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file)\n- [mypy](https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file)\n- [bandit](https://bandit.readthedocs.io/en/latest/config.html#bandit-settings)\n\nMinimal configuration example:\n```toml\n[tool.black]\nline-length = 88\ntarget-version = [\"py37\"]\n\n[tool.isort]\nprofile = \"black\"\n\n[tool.mypy]\ndisallow_untyped_defs = true\n\n[tool.bandit.assert_used]\nskips = [\"*_test.py\", \"*/test_*.py\"]\n\n[tool.pynalyzer]\npaths = [\"some_dir\", \"some_file.py\"] # Fill this with paths to dirs and files you want to analyze\n```\n\n\n> **Note** \n> 1. Other configuration files than `pyproject.toml`, e.g. `.bandit` will **not** be \n> taken into account when running `pynalyzer`.\n> Configuration for every code analysis tool will only be taken from `pyproject.toml`.\n> 2. `pynalyzer` is not configuring / forcing any configuration of \nany tool. \n> This approach gives you freedom of configuration, \nyou can configure every tool to suit your preferences and needs.\n\n \n## Usage\n\nMake sure you have done all the steps in [Prerequisites](#prerequisites) before running `pynalyzer`\n\n\n### Running static code analysis checks locally\n\nTo run all static code analysis checks:\n1. Go to project root directory (where you created `pyproject.toml` file)\n2. Execute `check` command (without any arguments):\n ```shell\n check\n ```\n This will run all the code analysis checks at once on all files \n and directories, one provided in `paths` in `pyproject.toml` configuration file.\n\n> **Note** \n> To not waste any time and / or resources, this command will **not** continue \n> to run other checks, if one of them failed. \n> \n> For example, if 2nd check (e.g. `isort`) failed, then 3rd and 4th checks won't execute. \n> Developer should firstly fix the issues that caused the 2nd check to fail, \n> in order to continue checking code with checks 3rd and 4th.\n> \n> This is done this way to be easy to use with CI/CD,\n> where every minute is precious using paid runners.\n\n\n### Automatically fixing code analysis issues\n\nSome code analysis issues can be automatically fixed:\n- code formatting (`black`) \n- import sorting (`isort`)\n\nTo run all fixes at once, one can use `fix` command:\n1. Go to project root directory (where you created `pyproject.toml` file)\n2. Execute `fix` command (without any arguments):\n ```shell\n fix\n ```\n\n\n## Credits\n\nImage used for logo was downloaded from: <a href=\"https://www.flaticon.com/free-icons/binary\" title=\"binary icons\">Binary icons created by Freepik - Flaticon</a>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Meta code analysis tool, bundling together multiple code analysis libraries",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/Devourian/pynalyzer",
"Repository": "https://github.com/Devourian/pynalyzer"
},
"split_keywords": [
"automation",
"code_quality",
"static_code_analysis",
"code_analysis",
"black",
"mypy",
"isort",
"bandit",
"cicd"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e66bbc227ee453c93e7bb1651fce70d14dc19da5718fa4ddb0bfd409e639b335",
"md5": "da299768f56299c8e7a088f7ec62b0db",
"sha256": "89dfde2cffa73dadb919c81d8760db1c3cbef5293778478c8f7e3788ad105b7e"
},
"downloads": -1,
"filename": "pynalyzer-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "da299768f56299c8e7a088f7ec62b0db",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 11464,
"upload_time": "2023-07-06T12:50:24",
"upload_time_iso_8601": "2023-07-06T12:50:24.618438Z",
"url": "https://files.pythonhosted.org/packages/e6/6b/bc227ee453c93e7bb1651fce70d14dc19da5718fa4ddb0bfd409e639b335/pynalyzer-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "601ab024f1c58e297f52d6acd7174e6db777a82f88e7dfc783ebbf7020880f2a",
"md5": "04a78e34b539969956006db1f84abb4f",
"sha256": "5ecc3e1f556500ee85e10a9be965fda174734a7e9dce573d70d2f332e9699eb8"
},
"downloads": -1,
"filename": "pynalyzer-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "04a78e34b539969956006db1f84abb4f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 10696,
"upload_time": "2023-07-06T12:50:26",
"upload_time_iso_8601": "2023-07-06T12:50:26.227350Z",
"url": "https://files.pythonhosted.org/packages/60/1a/b024f1c58e297f52d6acd7174e6db777a82f88e7dfc783ebbf7020880f2a/pynalyzer-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-06 12:50:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Devourian",
"github_project": "pynalyzer",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pynalyzer"
}