Skip to main content

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)
  • Project diagnostics with archetype doctor
  • Import graph export with archetype graph --format mermaid|json
  • Unmatched pattern warnings with suggestions for likely misspellings
  • 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.

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.4.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.4.0-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: archetype_py-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 37b1ab33c7ce82464ece3215274bb3e0859dee7c0a707aa2632bf93a2cfaf2a2
MD5 c97f64e6c32648389996b038a061fce5
BLAKE2b-256 a6ec782b1a43af9615bf2a996d0d6246be42b81ac6ec8c0cdc2e1f347f27c49d

See more details on using hashes here.

Provenance

The following attestation bundles were made for archetype_py-0.4.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.4.0-py3-none-any.whl.

File metadata

  • Download URL: archetype_py-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 41.4 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea67c39d1e287c26e009afeada80049b143b1192d70c855709b0b6602de45e4a
MD5 b9e7339cb56e0fe6e1e136abdfdae01d
BLAKE2b-256 2ef12d826c0cb1a87c855e9f57aa98899cd6e8e8b53c1caa460a347ce53e5aa9

See more details on using hashes here.

Provenance

The following attestation bundles were made for archetype_py-0.4.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.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 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