Python Code Analysis Tools
All tools should be configured to run automatically, except the once marked with a ⚒, which I would consider more suitable for ad-hoc usage. The tools I prefer are marked with ★.
- ★ black: Uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting.
- ★ isort: A Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.
- ★ mdformat-gfm: mdformat-plugin that changes the target specification to GitHub Flavored Markdown (GFM).
- ★ pydocstyle: Static analysis tool for checking compliance with Python docstring conventions.
- pyupgrade: Update parts of the code using more modern syntax.
- ★ autoflake: remove unused variables and imports.
- ★ mypy: Type checks Python Code. It can catch many programming errors by analyzing your program, without actually having to run it
- pyright: Fast type checker by Microsoft, meant for large Python source bases.
- ★ pylint: Static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions. Lot’s of extensions available!
- pyflakes: Pyflakes analyzes programs and detects various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It’s also much faster.
Reduce code complexity
- ★ ⚒ pydeps: Python module dependency visualization.
- ★ ⚒ vulture: Finds unused code in Python programs.
- ★ ⚒ radon: Tool that computes various metrics from the source code.
- ★ ⚒ wily: Uses git to go through each revision (commit) in a branch and reports complexity and code-analysis metrics.
Performance / Profiling
- ⚒ viztracer + vizplugins: VizTracer is a low-overhead logging/debugging/profiling tool that can trace and visualize your python code execution.
- airspeed velocity: tool for benchmarking Python packages over their lifetime.
- perflint: Pylint extension for performance anti patterns.
- ★ ⚒ py-spy: Sampling profiler, can export results to speedscope-format.
- ⚒ memray: Tracing memory profiler with nice reports and a live-view in terminal.
- ⚒ fastero:
timeit, but nicer.
- ⚒ pyinstrument: Statistical profiling (samples from callstack with little overhead).
- ⚒ eliot: For causal logging (tracing).
- airspeed velocity: Benchmark project through development lifetime.
- ⚒ libhunt.com: Maintenance and usage stats for Python libraries. Compare various packages against each other.
- ⚒ libraries.io: Assess maintenance and usage stats of Python libraries.
- ⚒ snyk.io: Search and compare over 1 million open source packages.
- Bandit: A security linter from PyCQA.
- safety: Checks installed dependencies for known vulnerabilities.
- pip-audit: Tool for scanning Python environments for packages with known vulnerabilities.
- pytest-parallel: Multiprocessing (or threading) to run tests faster.
- slipcover: Newer test coverage tool with less overhead than