Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PyArchRules Logo

License: MIT Python 3.12+ Status: Beta Documentation

PyArchRules

Architecture linter for Python.

Define your project's folder structure and import rules in pyproject.toml (or in Python) and enforce them in CI or from your test suite.

📚 Full documentation

Key features

  • Folder structure validation.
  • Directional dependency rules between modules.
  • Isolation between services and layers.
  • Circular import detection.

Quick start

1. Install

pip install pyarchrules

2. Define your rules

Option A — pyproject.toml (recommended)

# pyproject.toml
[tool.pyarchrules.services.backend]
path = "src/backend"

# Required folder structure
tree      = ["api", "domain", "infra"]
tree_mode = "strict"                       # exists / strict / exact

# Allowed import directions
dependencies = [
    "api -> domain",
    "domain -> infra",
]

# Prevent circular imports
no_circular_imports = true

Run it:

pyarchrules check

Option B — Python DSL (great for tests)

# tests/test_architecture.py
from pyarchrules import PyArchRules


def test_backend_architecture():
    rules = PyArchRules()
    (
        rules.for_service("backend")
             .tree_structure(["api", "domain", "infra"], mode="strict")
             .dependencies(["api -> domain", "domain -> infra"])
             .no_circular_imports()
    )
    rules.validate()

Run it:

pytest tests/test_architecture.py

Next steps

  • Configuration — full [tool.pyarchrules] reference.
  • Python DSL — every rule available as a fluent method.
  • Use Cases — monorepo and Clean Architecture patterns.

Contributing

See CONTRIBUTING.md.

License

MIT

Metadata

Release files for pyarchrules 0.1.0b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyarchrules 0.1.0b2
File Size Uploaded Provenance
pyarchrules-0.1.0b2.tar.gz 37.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyarchrules 0.1.0b2
File Interpreter ABI Platform
pyarchrules-0.1.0b2-py3-none-any.whl Python 3 none any Details

Total release size: 84.7 kB

Release files / pyarchrules-0.1.0b2.tar.gz

Download URL pyarchrules-0.1.0b2.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
580f62c1abf6655d91a96cf53e57d6ebf4728ba7c3829a84952fa0f71833f38c
BLAKE2b-256 checksum
How to use checksums
b7c604fa7459a1644eb5576a5d055604e785b6b1c032c5c550676817bab2afa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pyarchrules-0.1.0b2-py3-none-any.whl

Download URL pyarchrules-0.1.0b2-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cf5565213b1d8973786ba924dbc2799ccdf8f60418f07f58424cad2f94cc06c
BLAKE2b-256 checksum
How to use checksums
8d6b11fd7e17a31950b9e286cfebe5a1764f237712e43c358a0b4337afbdcd3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pyarchrules 0.1.0b2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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