Tools#
All tools below are installed automatically as dependencies of
core-dev-tools. They are grouped by purpose so you can quickly find what
you need for a given CI/CD stage or development workflow.
CLI Commands#
core-dev-tools ships a small CLI of its own, exposed through your project’s
manager.py via cli_dev. Wire it in once and every project gets the
same commands:
from click.core import CommandCollection
from core_dev_tools.cli.runner import cli_dev
CommandCollection(sources=[cli_dev])()
run-linters#
Runs all five linters and type checkers against a given package directory. All tools always run; failures are collected and reported together at the end.
python manager.py run-linters <package>
python manager.py run-linters <package> --tool ruff # Single tool
python manager.py run-linters <package> --tool mypy --tool ty # Multiple tools
Tools executed in order: ty check, ruff check, mypy --explicit-package-bases,
pyright, pylint.
run-security#
Runs security scanners against a given package directory. All tools always run; failures are collected and reported together at the end.
python manager.py run-security <package>
Tools executed in order: bandit -r <package>, pip-audit.
Package & Environment Management#
UV#
An extremely fast Python package and project manager, written in Rust.
More information: https://docs.astral.sh/uv/
uv [OPTIONS] <COMMAND>
Linting & Formatting#
Ruff Linter#
The Ruff Linter is an extremely fast Python linter designed as a drop-in replacement for Flake8 (plus dozens of plugins), isort, pydocstyle, pyupgrade, autoflake, and more.
More information: https://docs.astral.sh/ruff/linter/
ruff check # Lint files in the current directory.
ruff check --fix # Lint files in the current directory and fix any fixable errors.
ruff check --watch # Lint files in the current directory and re-lint on change.
ruff check path/to/code/ # Lint files in `path/to/code`.
PyLint#
Pylint is a tool that checks for errors in Python code, tries to enforce a coding standard (stricter/static code analyzer (if you want more opinions than ruff)) and looks for bad code smells.
More information: https://docs.pylint.org/
pylint <module_or_package>
Type Checking#
Mypy#
Mypy is an optional static type checker for Python that aims to combine the benefits of dynamic (or “duck”) typing and static typing.
More information:
mypy .
Pyright#
Pyright is a full-featured, standards-compliant static type checker for Python. It is designed for high performance and can be used with large Python source bases.
More information: https://microsoft.github.io/pyright
pyright
ty#
ty is an extremely fast Python type checker and language server written in Rust, developed by Astral (the creators of Ruff and uv). It is designed to be a high-performance alternative to mypy and pyright.
More information: https://docs.astral.sh/ty/
ty check # Type-check the current project.
ty check <path> # Type-check a specific file or directory.
Security & Compliance#
Bandit#
Bandit is a tool designed to find common security issues in Python code. To do this Bandit processes each file, builds an AST from it, and runs appropriate plugins against the AST nodes. Once Bandit has finished scanning all the files it generates a report.
More information: https://pypi.org/project/bandit/
bandit -r <path>
pip-audit#
It is a tool for scanning Python environments for packages with known vulnerabilities. It uses the Python Packaging Advisory Database (pypa/advisory-database) via the PyPI JSON API as a source of vulnerability reports.
More information: https://pypi.org/project/pip-audit/
pip-audit
Testing#
pytest#
pytest is a mature, full-featured Python testing framework. It makes it easy to write small, readable tests and scales to support complex functional testing for applications and libraries.
More information: https://docs.pytest.org/
pytest # Run all tests.
pytest tests/test_foo.py # Run a single test file.
pytest -k "test_name" # Run tests matching a keyword expression.
pytest -v # Run with verbose output.
pytest-cov#
pytest-cov is a pytest plugin that measures code coverage during test runs.
It integrates with the coverage package and supports parallel test
execution via pytest-xdist.
More information: https://pytest-cov.readthedocs.io/
pytest --cov=<source> # Run tests with coverage report.
pytest --cov=<source> --cov-report=html # Generate HTML coverage report.
pytest --cov=<source> --cov-report=term # Print coverage summary to terminal.
pytest-xdist#
pytest-xdist is a pytest plugin that extends pytest with distributed and parallel test execution modes. It allows tests to run across multiple CPUs or even remote machines.
More information: https://pytest-xdist.readthedocs.io/
pytest -n auto # Run tests in parallel using all available CPUs.
pytest -n <num> # Run tests in parallel using <num> workers.
coverage#
coverage measures code coverage of Python programs. It monitors which lines of your program are executed and which are not, making it easy to identify untested code.
More information: https://coverage.readthedocs.io/
coverage run -m pytest # Run tests and measure coverage.
coverage report # Print coverage summary to terminal.
coverage html # Generate HTML coverage report.
Tox#
It aims to automate and standardize testing in Python. It is part of a larger vision of easing the packaging, testing and release process of Python software (alongside pytest and devpi).
More information:
tox
Git Hooks#
pre-commit#
pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. It integrates with git to automatically run checks (linters, formatters, security scanners) before each commit.
More information: https://pre-commit.com/
pre-commit install # Install hooks into the git repository.
pre-commit run --all-files # Run all hooks against all files.
pre-commit autoupdate # Update hook versions to latest.
CLI & Configuration Utilities#
click#
Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It is highly configurable and comes with sensible defaults out of the box.
More information: https://click.palletsprojects.com/
@click.command()
@click.option("--name", prompt="Your name", help="The person to greet.")
def hello(name):
click.echo(f"Hello {name}!")
environs#
environs is a Python library for parsing environment variables. It makes
it easy to define expected types, default values, and validation rules
for environment-based configuration, with support for .env files.
More information: sloria/environs
from environs import Env
env = Env()
env.read_env() # Read .env file if it exists.
DEBUG = env.bool("DEBUG") # Parse and cast to bool.
PORT = env.int("PORT", 5000) # With a default value.
Task Automation#
taskipy#
The complementary task runner for python.
More information: https://pypi.org/project/taskipy/
task <task-name>
Documentation#
Sphinx#
Sphinx makes it easy to create intelligent and beautiful documentation.
More information: https://www.sphinx-doc.org/
sphinx-quickstart docs
cd docs
make html
Packaging & Publishing#
Build#
A simple, correct Python packaging build frontend. It manages pyproject.toml-based builds, invoking build-backend hooks as appropriate to build a distribution package. It is a simple build tool and does not perform any dependency management.
More information: https://pypi.org/project/build/
python -m build
Twine#
Twine is a utility for publishing Python packages to PyPI and other repositories. It provides build system independent uploads of source and binary distribution artifacts for both new and existing projects.
More information: https://twine.readthedocs.io/en/stable/
twine check dist/*
twine upload -u USER -p PASSWORD dist/*