Skip to content

Contributing

If you plan to contribute to the codebase, you need to set up the pre-commit hooks in addition to the standard installation. These hooks enforce code quality checks automatically on every commit.

Prerequisites

  • Python: Version 3.10 or newer is required.
  • uv: Version 0.13.1 or newer for package management (installation guide).

Development Setup

Clone the repository and navigate to the SDK directory:

cd mosaico/mosaico-sdk-py

Install dependencies and register the pre-commit hooks in a single step:

uv sync --locked --extra cli && uv run --locked --extra cli pre-commit install

The second command installs the Git hook under .git/hooks/pre-commit, wiring it to the rules defined in .pre-commit-config.yaml. From that point on, every git commit will automatically run Ruff (linting and formatting) against your staged files — the commit is blocked if any check fails, keeping the codebase consistently clean.

Why this matters: Skipping pre-commit install means your commits will bypass all quality gates. CI will catch the issues anyway, but fixing them after the fact is more disruptive than catching them locally before pushing.

What the hooks do

The .pre-commit-config.yaml currently configures the following actions via Ruff:

  • Linting — detects common errors, unused imports, and style violations
  • Formatting — auto-formats code to a consistent style

Running checks manually

You can trigger the hooks on demand without committing:

# Run on all files
uv run --locked --extra cli pre-commit run --all-files

# Run on staged files only
uv run --locked --extra cli pre-commit run

Verify the hook is installed

After setup, confirm the hook is in place:

ls ../.git/hooks/pre-commit

You should see the file present. If it is missing, re-run uv run --locked --extra cli pre-commit install.