Skip to main content

uv and quality tools

This repo treats CAD models like software, so the toolchain does more than install Python packages. It keeps the workspace reproducible, formats source files, catches typing mistakes, flags dead code, and gives the CI/CD pipeline the same checks developers can run locally.

If you only remember one command, use this one before you push:

just quality

It runs the local quality gate: linting plus the full test suite. Use the rest of this page when you need to understand what failed, run a smaller check, or change the tool configuration on purpose.

How the pieces fit​

The practical idea: catch the cheap problems before they become geometry problems. A formatting failure is easier to fix than a broken export found at release time.

Command map​

NeedCommandWhat it proves
Install or refresh toolsjust syncThe workspace has the Python dependencies from uv.lock.
Match the CI/CD pipeline installjust sync-frozenThe lockfile is current and installable without changing it.
Format source filesjust formatRuff can rewrite formatting consistently.
Run static checksjust lintRuff, mypy, and vulture agree the source is clean.
Run all testsjust testPytest can build, inspect, and export the models under test.
Run a fast test groupjust test-unit, just test-integration, just test-render, or just test-functionalThe relevant pytest marker group passes while you iterate.
Run the normal pre-push gatejust qualityStatic checks and the full test suite both pass.
Run artifact export verificationjust export-smokeRegistered artifacts can be discovered, realized, and exported.
Run the containerized CI/CD gatejust ciDagger can reproduce the check in the same style as GitHub Actions.

For the full justfile reference, see justfile recipes. For the Dagger side, see CI/CD pipeline and Dagger.

uv: the package and tool runner​

uv installs the project dependencies and runs commands inside the repo environment. In this template, it replaces the usual mix of pip, virtualenv commands, and hand-written activation steps.

Use:

just sync

when you change branches, edit dependencies, or open the repo in a fresh workspace.

Use:

just sync-frozen

when you want the same dependency strictness as the CI/CD pipeline. This should fail if pyproject.toml and uv.lock disagree.

Direct equivalents:

uv sync
uv sync --group dev --frozen

Dev dependencies include pytest, ruff, mypy, vulture, pre-commit, MakerRepo CLI support, MCP packages, and Dagger-facing tooling.

Ruff: style, imports, and formatting​

ruff is the formatter and first-pass linter. It keeps source files boring and consistent so reviews can focus on modeling changes instead of spacing, import order, or small style drift.

Run the check:

uv run ruff check .
uv run ruff format --check .

Apply formatting:

just format

Configuration lives in pyproject.toml under [tool.ruff]. The template uses a 100-character line length and Python 3.11 target.

The cad/parts/*.py files allow wildcard build123d imports (F403, F405) because that style is common in sketch-heavy CAD code. Keep that exception narrow; do not use it as a blanket escape hatch for the rest of the repo.

mypy: type checks for CAD code​

mypy checks the shape of the Python code before runtime. That matters in CAD work because many failures otherwise show up late: during viewer startup, export, or a CI/CD pipeline job.

Run:

uv run mypy cad cad_tooling tests cad_tooling_tests

The checked paths match the CI/CD pipeline. Configuration lives in pyproject.toml under [tool.mypy].

Current defaults:

SettingWhy it exists
python_version = "3.11"Matches the supported runtime.
explicit_package_bases = trueKeeps package discovery predictable in this template layout.
ignore_missing_imports = trueAvoids blocking on third-party CAD libraries without complete type stubs.

Prefer adding clear type hints at your own function boundaries over loosening the global mypy settings. Builders, exporters, and test helpers are much easier to review when their inputs and outputs are explicit.

Vulture: dead-code detection​

vulture scans for unused functions, classes, variables, and imports. In a CAD repo, this helps separate useful reusable geometry from old experiments that no longer feed an artifact, generator, test, or release export.

Run:

uv run vulture

Configuration lives in pyproject.toml under [tool.vulture].

Current scan scope:

SettingValue
pathscad, cad_tooling, tests, cad_tooling_tests, main.py, scripts, ci/src
exclude.venv, ci/.venv, ci/sdk, website, dist, __pycache__
min_confidence80

Some framework entry points look unused to static analysis because decorators or external tools discover them. The template already ignores the common decorators:

DecoratorWhy it may look unused
@artifact, @customizable, @cached, @renderMakerRepo discovers these at runtime.
@functionDagger exposes decorated functions as pipeline calls.
@pytest.fixturePytest injects fixtures into tests by name.

When vulture reports a false positive, do not delete live CAD code just to silence the check. First confirm whether the symbol is used through MakerRepo, Dagger, pytest, or another discovery path. If it is genuinely part of the public surface, add a focused ignore or whitelist entry and leave a short comment explaining why.

Pytest: model behavior, not just code behavior​

pytest runs the tests that prove the example CAD model still builds, exports, and behaves as expected.

Run everything:

just test

Run marker groups while iterating:

just test-unit # pure logic, config, discovery, template text
just test-integration # CAD geometry, export, release artifact behavior
just test-render # headless OCP PNG rendering
just test-functional # isolated just CLI recipes
just test-v # verbose full suite

Pass extra pytest arguments through just:

just test -v tests/test_sphere.py
just test-integration -k sphere

Good CAD tests usually assert observable properties:

AssertWhy
Valid solidsCatches broken geometry before export.
Bounding boxes, volume, feature countsCatches accidental dimensional changes.
Artifact discoveryProves MakerRepo can find publishable objects.
Scoped export checksProves manufacturing outputs still generate.

For markers, categorization, and the agent workflow, see Testing strategy.

Editor alignment​

Editor formatting should match the repo, not personal global settings. The Dev Container config and .vscode/settings.json point the editor at the environment version of Ruff and this repo's pyproject.toml.

Expected settings:

SettingValue
editor.defaultFormatterRuff
ruff.importStrategyfromEnvironment
ruff.configuration${workspaceFolder}/pyproject.toml

Do not use Black, autopep8, or the built-in Python formatter for this repo. They can produce formatting that differs from the CI/CD pipeline, which turns simple saves into noisy diffs.

Git hooks​

Install the local hooks once per clone:

just setup-hooks

This installs:

HookWhat it does
pre-commitRuns Ruff check, Ruff format, and vulture before a commit is created.
commit-msgChecks the commit subject follows the expected Conventional Commit shape.

Hooks are a convenience, not a replacement for just quality. Run the full local gate before pushing meaningful changes.

When a check fails​

Use the failing tool name to choose the fix path.

FailureUsual fix
ruff checkRead the rule message, fix the import/style issue, or run uv run ruff check . --fix when the rule is safely auto-fixable.
ruff format --checkRun just format, then inspect the diff.
mypyAdd or tighten types in your code. Avoid broad # type: ignore comments unless the library boundary really needs one.
vultureDelete truly unused code, or add a focused ignore/whitelist for framework-discovered entry points.
pytestFix the model, expected dimensions, fixture, marker, or export path. Do not loosen geometry assertions just to pass.
just sync-frozenRegenerate or commit the correct uv.lock change, then rerun the frozen sync.

A good repair loop is:

just lint
just test
just quality

Run the smallest command while debugging, then finish with the full local gate.

Local gate vs CI/CD pipeline​

just quality is the normal local gate. It is fast and does not require Docker.

just ci runs the Dagger pipeline. It needs Docker and is closer to what GitHub Actions runs for pull requests and main-branch changes.

Use just ci before merging larger changes, changing tooling, touching .github/workflows/**, or updating export/release behavior. Otherwise, just quality is the right daily habit.