Package: pynalyzer
pynalyzerMeta code analysis tool for Python, 
bundling together multiple code analysis libraries.Table of ContentsTable of ContentsAboutAdvantagesCI/CDInstallationPrerequisitesTools configurationUsageRunning static code analysis checks locallyAutomatically fixing code analysis issuesCreditsAboutThe main idea behindpynalyzeris to improve and simplify
experience of python developers using multiple code analysis
tools at once.pynalyzerprovides 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 issuesAdvantagespynalyzeris super simple to use with two easy to memorize commands:checkandfixpynalyzerisOS-independent, so you can use
it wherever you want:Windows / Linux / MacOSCMD / Powershell / Bash / zsh / othersIt is alsoproject-structure-independent, meaning
you can use it in all types of Python projects:projects containing onlyrequirements.txtfor dependenciesprojects usingsetup.pyfor dependencies and/or packagingproject usingpyproject.tomlfor dependencies and/or packagingetc.Easily configurable with industry standard -pyproject.tomlfileIt 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,
thatpynalyzerbundles (e.g.mypy) by configuring them throughpyproject.tomlfile.CI/CDThe main use-case forpynalyzeris 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.Usingpynalyzerin 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 inpynalyzer, as it will use the
same commands and the same configuration file to configure
code analysis tools, both on remote and locally.InstallationInstall usingpip:pipinstallpynalyzeror usingpoetry:poetryaddpynalyzerPrerequisitesIn order to successfully runpynalyzer, you need to:InstallpynalyzerpackageCreatepyproject.tomlfile in root directory of the project (if it doesn't already exist)Configurepynalyzer, by adding[tool.pynalyzer]section topyproject.tomlfileUnder[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"]Notepaths can be absolute or relative to project root directorypaths can lead to single file or to directory with filesConfigure static analysis tools inpyproject.tomlfile to suit your likingsTools configurationAll code analysis tools are configured throughpyproject.tomlfile,
which you need to put at the root of your project.For the instruction of how to configure each tool
usingpyproject.tomlcheck their docs:isortblackmypybanditMinimal configuration example:[tool.black]line-length=88target-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 analyzeNoteOther configuration files thanpyproject.toml, e.g..banditwillnotbe
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.UsageMake sure you have done all the steps inPrerequisitesbefore runningpynalyzerRunning static code analysis checks locallyTo run all static code analysis checks:Go to project root directory (where you createdpyproject.tomlfile)Executecheckcommand (without any arguments):checkThis will run all the code analysis checks at once on all filesand directories, one provided inpathsinpyproject.tomlconfiguration file.NoteTo not waste any time and / or resources, this command willnotcontinue
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 issuesSome code analysis issues can be automatically fixed:code formatting (black)import sorting (isort)To run all fixes at once, one can usefixcommand:Go to project root directory (where you createdpyproject.tomlfile)Executefixcommand (without any arguments):fixCreditsImage used for logo was downloaded from:Binary icons created by Freepik - Flaticon