Skip to main content

invoke-tasklib

Reusable Invoke tasks shared across Python projects.

Installation

Add invoke-tasklib as a dev dependency.

Usage

In your project's tasks.py:

from invoke_tasklib import ns

Set the required config in invoke.yaml at the project root:

tasklib:
  package:
    name: my_package

Then list the available tasks:

invoke --list

Tasks

Tasks are organized into namespaces: format.*, lint.*, types.*, test.*, env.*, release.*, doc.*.

format.* and lint.*

Tasks that check or verify something (never modify files, exit non-zero on violations) are named check_<target>. Tasks that modify files in place are named fix_<target>. Both share the same <target> (e.g. python, shell, docstrings) so the read-only/mutating counterpart of a task is easy to find:

Task Behavior
format.check-python Checks Python formatting with ruff (read-only)
format.check-docstrings Checks docstring formatting with docformatter (read-only)
format.check-shell Checks shell scripts with shellcheck (read-only)
format.fix-python Formats Python code with ruff (in place)
format.fix-docstrings Formats docstrings with docformatter (in place)
format.fix-shell Formats shell scripts with shfmt (in place)
lint.check-lint Checks linting with ruff (read-only)

When adding a new task to these namespaces, follow this convention: pick check_ or fix_ based on whether the task mutates files, and use a <target> name that matches its read-only/mutating counterpart if one exists.

types.*

Task Behavior
types.check Checks type hints with pyright (read-only)

test.*

Task Behavior
test.doctest Runs doctests on source code
test.unit Runs unit tests
test.integration Runs integration tests
test.functional Runs functional tests
test.all Runs all tests (unit, integration, and functional)
test.benchmark Runs performance benchmarks

env.*

Task Behavior
env.create-venv Creates a virtual environment and installs invoke
env.install Installs project dependencies and the package (editable)
env.update Updates dependencies and pre-commit hooks
env.show-installed-packages Shows the installed packages
env.show-python-config Shows the Python configuration

release.*

Task Behavior
release.build Builds the package and verifies installation (--check also validates metadata with twine)
release.pypi Builds and publishes the package to PyPI

doc.*

Task Behavior
doc.publish-dev Publishes development (unstable) docs
doc.publish-latest Publishes latest (stable) docs

Config

Only tasklib.package.name is required. Everything else has a default derived from it. Full schema:

tasklib:
  package:
    name: my_package # required
    python_version: "3.14" # used by env.create-venv
  paths:
    src: src/my_package # default: src/<package.name>
    tests: tests
    unit_tests: tests/unit # default: <tests>/unit
    integration_tests: tests/integration # default: <tests>/integration
    functional_tests: tests/functional # default: <tests>/functional
    benchmarks: tests/benchmarks # default: <tests>/benchmarks
    docs_config: docs/mkdocs.yml

Composing a custom subset of tasks

If a project needs a different set of tasks, or a one-off task alongside the shared ones, import individual task modules instead of the pre-built ns:

from invoke import Collection
from invoke_tasklib import lint, test

from . import my_custom_task

ns = Collection(lint, test, my_custom_task)

Prefer adding a config knob to a shared task over forking it; reserve custom composition for things that are genuinely one-off to a single project.

Release files for invoke-tasklib 0.0.1

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

Source distribution (sdist)

Source distribution for invoke-tasklib 0.0.1
File Size Uploaded
invoke_tasklib-0.0.1.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for invoke-tasklib 0.0.1
File Interpreter ABI Platform
invoke_tasklib-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / invoke_tasklib-0.0.1.tar.gz

Download URL invoke_tasklib-0.0.1.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
71244d98f3d233ab29a584501c024d1cee0fd687c0064674144a4b6672b791c5
BLAKE2b-256 checksum
How to use checksums
9151379a817e8db69cc0532fd3679c90dc8dc416ebd7105f4d783da64230a948
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / invoke_tasklib-0.0.1-py3-none-any.whl

Download URL invoke_tasklib-0.0.1-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17e316cff033394094c6006b1f53d398a8d8eac9f0cabc078b5541a344e27360
BLAKE2b-256 checksum
How to use checksums
a0a7a8cdfda653f56c719022ca0e109eb7158d7b97eccde98eb4840b0a7d4aeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.0.6

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

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