Skip to main content

Enforce architectural rules as code. Catch structural violations before they merge.

Project description

archetype-py

Enforce architectural rules as code. Catch structural violations before they merge.

GitHub Repository
Documentation

Why archetype-py

Most tooling checks formatting, typing, and tests, but not architecture drift.
archetype-py lets you codify structural boundaries and enforce them in local runs, CI, and pytest.

When to use / When not to use

Use archetype-py when:

  • You want architecture rules to run automatically in CI and pytest.
  • You need to prevent forbidden imports, layer violations, or import cycles.
  • You are adopting architecture checks incrementally in a legacy codebase (baseline mode).

Do not use archetype-py when:

  • You only need style/type checks (linters and type checkers are enough).
  • Your project is a very small script with no meaningful module boundaries.
  • You are looking for runtime policy enforcement instead of static import-graph checks.

Install

pip install archetype-py

Quick Start

archetype init .
archetype check .

Create an architecture.py file and define your rules:

from archetype import rule
from archetype.rules import layers

@rule("layers are ordered")
def layer_order() -> None:
    layers(["myapp.api", "myapp.services", "myapp.db"]).are_ordered()

Core Features

  • Architecture rules for forbidden imports, allowlisted imports, and protected boundaries
  • Transitive dependency checks with must_not_depend_on
  • Layer order enforcement with layers(...).are_ordered()
  • Import cycle detection with no_cycles(...)
  • Rule decorators: @rule, @warn, @skip, @since
  • Rule grouping via group("...") and targeted execution with --group
  • archetype init scaffolding for starter architecture.py
  • JSON and text reporting (--format json|text) with stable JSON contract versioning
  • Quiet output mode (--quiet) for CI-friendly logs
  • Import graph caching for faster repeated runs (--cache, --no-cache)
  • Parallel execution control with --workers
  • Baseline adoption for legacy codebases (--write-baseline, --baseline)
  • Changed-files scope mode (--changed-from <git-ref>)
  • GitHub Actions inline PR annotations (--github-annotations)
  • Path exclusions via CLI (--exclude) and config
  • Project config defaults through archetype.toml
  • Git pre-commit hook installer (archetype install-hook)
  • Project layout support for flat, src/, namespace packages (PEP 420), and monorepos
  • CLI command and pytest plugin support for local and CI enforcement

CI Example

- run: archetype check .

For full guides, examples, and release notes, use the GitHub README and changelog.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

archetype_py-0.3.0.tar.gz (7.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

archetype_py-0.3.0-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

Details for the file archetype_py-0.3.0.tar.gz.

File metadata

  • Download URL: archetype_py-0.3.0.tar.gz
  • Upload date:
  • Size: 7.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for archetype_py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 697012e2a32ca82701d25eab67c34a9b726b92d967dea33dad7b66466308f908
MD5 30c9396ecc55a74b46e0a1bf1056b50c
BLAKE2b-256 6dbab1d3616a642723e9382e36073fa64d99b9243c18e737899c1436c7fed860

See more details on using hashes here.

Provenance

The following attestation bundles were made for archetype_py-0.3.0.tar.gz:

Publisher: publish.yml on MossabArektout/archetype-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file archetype_py-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: archetype_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for archetype_py-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d66dfd3ff3bed63c484d6d32fdb4af34bea65921a9ce85d7c388fd4bce730e9
MD5 c17c11207ff6740e2e28fbdac272e7fb
BLAKE2b-256 7b6842b09056369c7353e0657a3e84921552f90dc6f24d1db2d666602973c849

See more details on using hashes here.

Provenance

The following attestation bundles were made for archetype_py-0.3.0-py3-none-any.whl:

Publisher: publish.yml on MossabArektout/archetype-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page