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 initscaffolding for starterarchitecture.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
697012e2a32ca82701d25eab67c34a9b726b92d967dea33dad7b66466308f908
|
|
| MD5 |
30c9396ecc55a74b46e0a1bf1056b50c
|
|
| BLAKE2b-256 |
6dbab1d3616a642723e9382e36073fa64d99b9243c18e737899c1436c7fed860
|
Provenance
The following attestation bundles were made for archetype_py-0.3.0.tar.gz:
Publisher:
publish.yml on MossabArektout/archetype-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
archetype_py-0.3.0.tar.gz -
Subject digest:
697012e2a32ca82701d25eab67c34a9b726b92d967dea33dad7b66466308f908 - Sigstore transparency entry: 1635292827
- Sigstore integration time:
-
Permalink:
MossabArektout/archetype-py@1f573178667988db05bf8f0682e4ae15199fe188 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/MossabArektout
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f573178667988db05bf8f0682e4ae15199fe188 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d66dfd3ff3bed63c484d6d32fdb4af34bea65921a9ce85d7c388fd4bce730e9
|
|
| MD5 |
c17c11207ff6740e2e28fbdac272e7fb
|
|
| BLAKE2b-256 |
7b6842b09056369c7353e0657a3e84921552f90dc6f24d1db2d666602973c849
|
Provenance
The following attestation bundles were made for archetype_py-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on MossabArektout/archetype-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
archetype_py-0.3.0-py3-none-any.whl -
Subject digest:
8d66dfd3ff3bed63c484d6d32fdb4af34bea65921a9ce85d7c388fd4bce730e9 - Sigstore transparency entry: 1635292832
- Sigstore integration time:
-
Permalink:
MossabArektout/archetype-py@1f573178667988db05bf8f0682e4ae15199fe188 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/MossabArektout
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f573178667988db05bf8f0682e4ae15199fe188 -
Trigger Event:
push
-
Statement type: