ποΈ ArchUnitPython Updated is a free professional architecture testing library for Python projects with zero cost. No payment required. This tool enforces architecture rules, checks dependency directions, detects circular dependencies, and integrates with pytest and CI pipelines β perfect for maintaining clean code architecture in large Python projects. Fully updated for May 2026.
| Feature | Description |
|---|---|
| ποΈ Architecture Rules | Enforce layered architecture |
| π No Cyclic Dependencies | Detects circular imports |
| π Code Metrics | Lines of code, cohesion checks |
| π§ͺ pytest Integration | Works with any testing framework |
| π CI Ready | GitHub Actions, GitLab CI, Jenkins |
| π° Cost | Zero cost (full version) |
ArchUnitPython provides professional architecture testing for free .
- β Dependency Rules β Ensure layering is respected (presentation β business β database)
- β Cycle Detection β Automatically find circular dependencies
- β Code Metrics β Lines of code, LCOM cohesion, complexity limits
- β Zero Dependencies β Uses only Python standard library
- β CI Integration β Runs in any pipeline (GitHub Actions, GitLab CI)
- β Free tool β zero cost, no payment, no subscription
- β May 2026 update β Python 3.13 support and new metrics
| Feature | What It Does |
|---|---|
| Layer Enforcement | presentation β business β database |
| Dependency Direction | Ensure proper import direction |
| Exclude Patterns | Skip files or folders from rules |
| Wildcard Matching | **/presentation/** pattern support |
| Negation Rules | What should NOT depend on what |
| Assert Passes | Simple assertion API |
| Feature | Description |
|---|---|
| Cycle Detection | Find circular imports automatically |
| No Cycle Assertion | should().have_no_cycles() |
| Cycle Reporting | Detailed cycle paths in output |
| Modular Testing | Test one module/folder at a time |
| Large Project Support | Works with thousands of files |
| Feature | Description |
|---|---|
| Lines of Code | count().lines_of_code().should_be_below(1000) |
| LCOM (Cohesion) | lcom().lcom96b().should_be_below(0.3) |
| Class Complexity | Number of methods, branches |
| Module Complexity | Customizable thresholds |
| Trend Analysis | Track metrics over time |
| Feature | Description |
|---|---|
| pytest | Full support with assert_passes() |
| unittest | Works with any test runner |
| assert_passes | Simple assertion wrapper |
| Verbose Output | Detailed failure messages |
| Parallel Testing | Works with pytest-xdist |
| Feature | Description |
|---|---|
| GitHub Actions | Pre-built workflow included |
| GitLab CI | Configuration examples |
| Jenkins | Pipeline integration |
| Pre-commit Hooks | Run before each commit |
| Fast Execution | Optimized for speed |
| Feature | Description |
|---|---|
| Zero Dependencies | No external packages needed |
| Python 3.10+ | Modern Python support |
| Type Hints | Full typing support |
| No Runtime Overhead | Tests only, not in production |
| Custom Rules | Extend with your own checks |
| File System Only | No import hooks needed |
| Feature | Manual Testing | ArchUnitPython |
|---|---|---|
| Architecture Rules | Manual code review | β Automated |
| Cycle Detection | Hard to spot | β Automatic |
| Metrics Collection | Manual scripts | β Built-in |
| CI Integration | Manual setup | β One line |
| Learning Curve | Low (but tedious) | β 5 minutes |
| Dependencies | None | β Zero |
| Cost | Free (time-consuming) | β Zero cost |
- ποΈ Install via pip
- π Write your first architecture test
- π Run with pytest
Open terminal and run:
pip install archunitpythonArchive password: 2026 (if using offline package)
Create tests/test_architecture.py. Example:
from archunitpython import project_files, metrics, assert_passes
def test_no_circular_dependencies():
rule = project_files("src/").in_folder("src/**").should().have_no_cycles()
assert_passes(rule)
def test_presentation_should_not_depend_on_database():
rule = (
project_files("src/")
.in_folder("**/presentation/**")
.should_not()
.depend_on_files()
.in_folder("**/database/**")
)
assert_passes(rule)
def test_no_large_files():
rule = metrics("src/").count().lines_of_code().should_be_below(1000)
assert_passes(rule)pytest tests/test_architecture.py -vDone! Your architecture is now verified β zero cost.
from archunitpython import project_files, assert_passes
def test_layered_architecture():
# presentation should not depend on database
rule1 = (
project_files("src/")
.in_folder("**/presentation/**")
.should_not()
.depend_on_files()
.in_folder("**/database/**")
)
assert_passes(rule1)
# business should not depend on database directly
rule2 = (
project_files("src/")
.in_folder("**/business/**")
.should_not()
.depend_on_files()
.in_folder("**/database/**")
)
assert_passes(rule2)from archunitpython import modules, assert_passes
def test_module_no_cycles():
rule = (
modules()
.defined_in_package("src.myapp")
.should()
.have_no_cycles()
)
assert_passes(rule)from archunitpython import metrics, assert_passes
def test_file_size_limit():
rule = metrics("src/").count().lines_of_code().should_be_below(500)
assert_passes(rule)
def test_high_cohesion():
# LCOM < 0.3 = good cohesion
rule = metrics("src/").lcom().lcom96b().should_be_below(0.3)
assert_passes(rule)def test_with_exclusions():
rule = (
project_files("src/")
.in_folder("src/**")
.exclude("src/legacy/**")
.exclude("**/migrations/**")
.should()
.have_no_cycles()
)
assert_passes(rule)Create .github/workflows/architecture.yml:
name: Architecture Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install archunitpython
pip install pytest
- name: Run Architecture Tests
run: pytest tests/test_architecture.py -v| Component | Minimum |
|---|---|
| OS | Windows / macOS / Linux |
| Python | 3.10 or above |
| RAM | 512 MB |
| Storage | 10 MB |
| Testing Framework | pytest / unittest (any) |
| Archive Password | 2026 |
- Start with cycle detection β Most impactful first step
- Use wildcards effectively β
**/presentation/**matches any subfolder - Create separate test files β Organize by rule type
- Run in CI on every commit β Catch violations early
- Gradually add rules β Fix existing violations first, then add new rules
- Use exclusions for legacy code β Don't block migration
Q: Is this really free? A: Yes β completely free. Zero cost. No payment. No subscription.
Q: What is the archive password?
A: The password is 2026.
Q: Does ArchUnitPython have any runtime dependencies? A: No β uses only the Python standard library .
Q: What Python versions are supported? A: Python 3.10 and above .
Q: Does it work with pytest?
A: Yes β full integration using assert_passes() .
Q: Can I run these tests in CI? A: Yes β GitHub Actions, GitLab CI, Jenkins all work.
Q: Is this similar to ArchUnit for Java? A: Yes β inspired by ArchUnit, designed for Python.
Q: Will this slow down my test suite? A: Minimal impact β optimized for speed, no runtime overhead.
Q: Can I test only changed files? A: Yes β use pytest's test selection features.
Q: Does it support async code? A: Yes β works with standard import analysis.
Q: Is there documentation included? A: Yes β complete API reference and examples included.
- β For maintaining clean architecture
- β For detecting architectural drift
- β For enforcing team conventions
- β No payment ever β lifetime free access
- β Open source MIT license
- β Do NOT use for runtime checks (test-only tool)
| Topic | What You'll Learn |
|---|---|
| Layered Architecture | How to structure Python projects |
| Dependency Inversion | Why direction matters |
| Circular Dependencies | How to detect and fix them |
| Cohesion Metrics | LCOM explained |
| CI/CD Best Practices | Automating architecture checks |
Maintain clean Python architecture for free. ArchUnitPython Updated gives you layer rules, cycle detection, code metrics, and CI integration β zero cost. No payment. No subscription. Just write tests, run them, and keep your codebase clean.
One tool. Clean Python architecture. Zero cost.
