Skip to main content

Bastet

Bastet, the cat god, takes all of our tests and puts them in one basket.

Bastet is another attempt to simplify linting and testing python projects. It runs a range of linting tools, parses the output, and outputs reports in different formats based on the use case.

The aim of these tools is that, if you run them on a code base, you should end up with something which conforms to your organisations style guidelines, and passes a variety of

Functionality

While developing mewbot we built a number of tools to assist with development.

This mostly consist of tool chains for:

  • Automatically reformatting code.
  • Managing license / copyright information.
  • Running static analysis tooling.
  • Checking the code base against style requirements.
  • Running unit tests.

And it can output in a variety of ways:

  • Simple lists of issues for local development.
  • CI output format for GitHub workflows
  • Reports for ingestion by Sonar.

Usage

The dev tools uses path based auto-discovery to locate the relevant code. Python modules will be discovered in folders called src and test which are not exclude by version control.

If your project is in that src-dir layout, you can install bastet and then run any of the toolchains.

pip install bastet

# Runs all the tools
bastet

# You can also run just some tools or sections
bastet --help
bastet --skip format pylint

We also recommend that you set up bastet as a pre-commit or pre-push hook.

Configuration

The default unconfirmed mode of Bastet is to run all of its tools (be they code formatting, linting, or auditing) and outputting a list of issues.

The recommended pyproject.toml to set up your project can be found in the examples folder. It enables all of the ruff linting rules, excluding a few which conflict with each other. It also disables the black and isort formatting tools, which ruff provides an implementation of.

Advance Config and Debug

You can check what the configuration is doing with --debug the debug flag on a run, or by running python -m bastet.config to just run the configuration steps.

Integration with Sonar

Using the sonar reporter will output a number of files into reports for Sonar to ingest.

Ensure that Sonar is above to read the output from Bastet's run in your CI setup, and then configure the following properties in Sonar's admin or your sonar-project.properties file:

sonar.python.coverage.reportPaths=reports/coverage.xml
sonar.python.xunit.reportPaths=reports/junit-*.xml
sonar.python.ruff.reportPaths=reports/ruff.txt
sonar.python.pylint.reportPaths=reports/pylint.txt

Integration with Gitlab

Bastet can produce up to three reports that GitLab can directly integrate into merge requests (code quality, test results, and coverage) using the gitlab reporter. A sample CI stage can be found in examples/gitlab-ci.yml.

Metadata

Release files for bastet 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bastet 0.2.0
File Size Uploaded
bastet-0.2.0.tar.gz 36.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bastet 0.2.0
File Interpreter ABI Platform
bastet-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 80.1 kB

Release files / bastet-0.2.0.tar.gz

Download URL bastet-0.2.0.tar.gz
Size 36.3 kB
Tags Source
SHA-256 checksum
How to use checksums
67f607e344952c2506180911016dcf9480a08e2faa82259306100e8a75da6b50
BLAKE2b-256 checksum
How to use checksums
d13de0776b219c6a8dee04783ba237c71628893f14c05478dd49bfe3fac71704
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / bastet-0.2.0-py3-none-any.whl

Download URL bastet-0.2.0-py3-none-any.whl
Size 43.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
492a0cc325713ff4e50c6e7f83adad646e2361a66a733d5a1691e76aca9e3a5f
BLAKE2b-256 checksum
How to use checksums
8cc08ec03619cd9d02472dc13623f768037b98ac86535e5518fbcc98a5daa56d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page