python¶
The python archetype is uv-native. It covers repos whose primary language is Python: a package or application (ruff,
pytest, uv build), a Zensical documentation site (the org site, podcast-workflow, and this site), or both.
# mise.toml
[task_config]
includes = [".mise/common/tasks.toml", ".mise/archetypes/python/tasks.toml"]
No Python pin needed¶
The shared uv pin provisions everything:
- The interpreter, from the repo's
.python-versionorrequires-python. - The project environment, from
pyproject.tomlanduv.lock.
A repo that wants a mise-managed Python adds python = "…" to its root [tools].
ruff, pytest and pytest-cov come from the project's own dev dependencies, so the repo controls their versions. A project without them, such as a docs-only site, skips those passes with a message rather than failing.
Tasks¶
| Task | What it does |
|---|---|
fmt |
License headers first, then ruff format and ruff check --fix, then prose format. |
lint |
license check, ruff check and ruff format --check, containers, shell, workflows, prose. |
test |
pytest with a JUnit report (and Cobertura coverage when pytest-cov is installed). |
build |
uv build and/or zensical build, depending on what the project declares. |
ci |
lint, test, build. |
pr |
fmt, lint, test, build, commit. |
Every Python task depends on a hidden sync task (uv sync), so the environment is always current. docs-build and
serve come from common, like every other repo's.
Why license runs first here
The other archetypes inject license headers last. Here it runs first because addlicense inserts the header with one blank line after it, and ruff format wants two before a top-level definition. Running ruff after addlicense lets it fix the spacing.
What build builds¶
build looks at the project and builds whatever it declares:
uv build(sdist and wheel intodist/) whenpyproject.tomlhas a[build-system]table;zensical build(the site intosite/) when azensical.tomlis present;- both, if both apply, or neither, with a message.
A docs-only site has a pyproject.toml with zensical as a dependency and no [build-system], so build is just the
site build. That's the reason to pick this archetype for one: common alone gives it docs-build and serve, but no
build, so CI would never build the site.
What test writes¶
coverage/junit.xml: always, when pytest is installed.coverage/coverage.xml: Cobertura, when pytest-cov is installed (--cov --cov-report=xml).coverage/.coverage: the raw coverage data file.
A suite that collects no tests (pytest exit code 5) passes with a message instead of failing.
A docs-only site¶
The minimal docs site looks like this:
my-site/
├── .mise/ # the toolchain
├── docs/index.md
├── overrides/ # optional theme overrides
├── pyproject.toml # dependencies = ["zensical>=…"], no [build-system]
├── uv.lock
├── zensical.toml
├── mise.toml # common + python
└── Makefile # include .mise/archetypes/python/include.mk
Add site/ and .venv/ to .gitignore, and site/** to .licenseignore. The reusable release workflow runs
mise run docs-build and publishes the site to GitHub Pages on each release whenever a zensical.toml sits at the repo
root.
Source¶
archetypes/python/tasks.toml
# Copyright 2026 BitWise Media Group Ltd
# SPDX-License-Identifier: MIT
#
# python — archetype for a repo whose primary language is Python: a package
# or application (ruff + pytest + `uv build`) and/or a Zensical documentation
# site (bitwise-media-group.github.io, podcast-workflow).
#
# Include AFTER common/tasks.toml in the consumer's root mise.toml:
# [task_config]
# includes = [".mise/common/tasks.toml", ".mise/archetypes/python/tasks.toml"]
#
# uv-native: the shared `uv` pin provisions the interpreter itself, from the
# repo's .python-version / requires-python, and the project environment from
# pyproject.toml + uv.lock. No mise python pin is needed (a repo that wants
# one adds `python = "…"` to its root [tools]). ruff and pytest come from the
# project's own dev dependencies, so the repo controls their versions; a
# project without them (a docs-only site) skips those passes with a message
# rather than failing — see scripts/. The house prose format/lint runs
# alongside ruff: ruff owns the code, bun fmt + markdownlint own the
# markdown. `docs-build` and `serve` come from common; what this archetype
# adds for a docs site is that `build` (and so CI) builds it too.
# Provision the project environment (Python + locked dependencies).
[sync]
hide = true
dir = "{{cwd}}"
run = "uv sync"
# Auto-fix pass wired into `fmt`: ruff format, then ruff check --fix.
[py-fmt]
hide = true
dir = "{{cwd}}"
depends = ["sync"]
run = "{{config_root}}/.mise/archetypes/python/scripts/ruff.sh fmt"
# Check-mode pass wired into `lint`: ruff check, then ruff format --check.
[py-lint]
hide = true
dir = "{{cwd}}"
depends = ["sync"]
run = "{{config_root}}/.mise/archetypes/python/scripts/ruff.sh check"
# pytest with coverage → coverage/ (see scripts/test.sh).
[py-test]
hide = true
dir = "{{cwd}}"
depends = ["sync"]
run = "{{config_root}}/.mise/archetypes/python/scripts/test.sh"
# `uv build` for a packaged project and/or `zensical build` for a docs site
# (see scripts/build.sh).
[py-build]
hide = true
dir = "{{cwd}}"
depends = ["sync"]
run = "{{config_root}}/.mise/archetypes/python/scripts/build.sh"
# license runs FIRST here (the other archetypes run it last): addlicense
# inserts the header with one blank line after it, and ruff format wants two
# before a top-level definition, so the ruff pass must see the header.
[fmt]
description = "inject license headers, ruff format + fix, prose format"
run = [{ task = "license" }, { task = "py-fmt" }, { task = "fmt-prose" }]
[lint]
description = "ruff check + prose, license, container, shell and workflow checks"
run = [
{ task = "license-check" },
{ task = "py-lint" },
{ task = "lint-containers" },
{ task = "lint-shell" },
{ task = "lint-workflows" },
{ task = "lint-prose" },
]
[build]
description = "uv build (package) and/or zensical build (docs site)"
run = [{ task = "py-build" }]
[test]
description = "pytest with coverage"
run = [{ task = "py-test" }]
[ci]
description = "the gates the reusable CI workflow runs"
run = [{ task = "lint" }, { task = "test" }, { task = "build" }]
[pr]
description = "full local gate before a pull request"
run = [
{ task = "fmt" },
{ task = "lint" },
{ task = "test" },
{ task = "build" },
{ task = "commit" },
]
archetypes/python/scripts/build.sh
#!/bin/sh
# Copyright 2026 BitWise Media Group Ltd
# SPDX-License-Identifier: MIT
#
# Build whatever the project declares: `uv build` (sdist + wheel into dist/)
# when pyproject.toml has a [build-system] table, and `zensical build` (the
# docs site into site/) when a zensical.toml is present — either, both, or,
# with a message, neither.
set -eu
built=0
if [ -f pyproject.toml ] && grep -q '^\[build-system\]' pyproject.toml; then
echo "py-build: uv build"
uv build
built=1
fi
if [ -f zensical.toml ]; then
echo "py-build: zensical build"
uv run --no-sync zensical build
built=1
fi
[ "$built" -eq 1 ] || echo "py-build: nothing to build (no [build-system] in pyproject.toml, no zensical.toml)"
archetypes/python/scripts/test.sh
#!/bin/sh
# Copyright 2026 BitWise Media Group Ltd
# SPDX-License-Identifier: MIT
#
# pytest from the project's own environment, with a JUnit report and — when
# pytest-cov is a dev dependency — a Cobertura coverage report, both under
# coverage/ (where the reusable CI workflow uploads from). A project without
# pytest in its environment (a docs-only site) is skipped with a message;
# so is a suite that collects no tests (pytest exit code 5).
set -eu
has_module() { uv run --no-sync python -c "import $1" >/dev/null 2>&1; }
if ! has_module pytest; then
echo "py-test: pytest is not in the project environment (add it to the dev dependencies); skipping"
exit 0
fi
mkdir -p coverage
export COVERAGE_FILE=coverage/.coverage
set -- --junitxml=coverage/junit.xml
if has_module pytest_cov; then
set -- "$@" --cov --cov-report=term --cov-report=xml:coverage/coverage.xml
fi
status=0
uv run --no-sync pytest "$@" || status=$?
if [ "$status" -eq 5 ]; then
echo "py-test: no tests collected; skipping"
exit 0
fi
exit "$status"