archunitpython 1.1.2__tar.gz → 1.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- archunitpython-1.2.1/.github/FUNDING.yml +1 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/CHANGELOG.md +25 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/PKG-INFO +161 -6
- {archunitpython-1.1.2 → archunitpython-1.2.1}/README.md +160 -5
- {archunitpython-1.1.2 → archunitpython-1.2.1}/pyproject.toml +1 -1
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/__init__.py +9 -1
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/extraction/extract_graph.py +122 -29
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/pattern_matching.py +1 -3
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/cycles/johnsons_apsp.py +4 -9
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/cycles/tarjan_scc.py +2 -6
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/project_cycles.py +1 -2
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/util/logger.py +1 -3
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/assertion/custom_file_logic.py +3 -9
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/assertion/depend_on_external_modules.py +3 -8
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/assertion/depend_on_files.py +4 -12
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/fluentapi/files.py +9 -27
- archunitpython-1.2.1/src/archunitpython/graph/__init__.py +35 -0
- archunitpython-1.2.1/src/archunitpython/graph/graph_reporter.py +795 -0
- archunitpython-1.2.1/src/archunitpython/layers/__init__.py +8 -0
- archunitpython-1.2.1/src/archunitpython/layers/assertion/__init__.py +9 -0
- archunitpython-1.2.1/src/archunitpython/layers/assertion/layer_dependencies.py +83 -0
- archunitpython-1.2.1/src/archunitpython/layers/fluentapi/__init__.py +6 -0
- archunitpython-1.2.1/src/archunitpython/layers/fluentapi/layers.py +116 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/assertion/metric_thresholds.py +1 -3
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/calculation/distance.py +1 -3
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/extraction/extract_class_info.py +3 -9
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/fluentapi/export_utils.py +2 -6
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/fluentapi/metrics.py +12 -38
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/fluentapi/slices.py +4 -12
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/uml/generate_rules.py +2 -6
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/testing/common/violation_factory.py +11 -3
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/test_extract_graph.py +166 -19
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/files/test_files_fluentapi.py +17 -70
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/metrics_project/service.py +1 -2
- archunitpython-1.2.1/tests/graph/test_graph_reporter.py +293 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/integration/test_e2e.py +13 -6
- archunitpython-1.2.1/tests/layers/test_layers.py +86 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/metrics/test_export.py +2 -6
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/metrics/test_metrics.py +5 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/metrics/test_metrics_fluentapi.py +53 -31
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/slices/test_slices.py +36 -9
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.editorconfig +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.gitattributes +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/CODEOWNERS +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/ISSUE_TEMPLATE/documentation.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/ISSUE_TEMPLATE/question.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/PAGES.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/dependabot.yml +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/pull_request_template.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/workflows/docs.yaml +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/workflows/integrate.yaml +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.github/workflows/stale.yaml +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.gitignore +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/.releaserc.json +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/BACKLOG.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/CONTRIBUTING.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/LICENSE +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/assets/logo-rounded.png +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/research/product-direction/architecture-testing-landscape.md +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/scripts/bump_release_version.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/scripts/check_release_metadata.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/assertion/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/assertion/violation.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/error/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/error/errors.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/extraction/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/extraction/graph.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/fluentapi/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/fluentapi/checkable.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/logging/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/logging/types.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/cycles/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/cycles/cycle_utils.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/cycles/cycles.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/cycles/model.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/edge_projections.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/project_edges.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/project_nodes.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/projection/types.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/regex_factory.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/types.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/util/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/common/util/declaration_detector.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/assertion/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/assertion/cycle_free.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/assertion/matching_files.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/files/fluentapi/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/assertion/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/calculation/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/calculation/count.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/calculation/lcom.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/common/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/common/types.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/extraction/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/fluentapi/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/metrics/projection/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/py.typed +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/assertion/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/assertion/admissible_edges.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/fluentapi/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/projection/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/projection/slicing_projections.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/uml/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/slices/uml/export_diagram.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/testing/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/testing/assertion.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/testing/common/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/testing/common/color_utils.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/src/archunitpython/testing/pytest_plugin/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/test_core_types.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/test_cycles.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/test_declaration_detector.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/test_logger.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/test_pattern_matching.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/common/test_projection.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/files/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/files/test_file_assertions.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/architecture.puml +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/controllers/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/controllers/controller.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/models/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/models/model.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/services/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/services/service.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/services/service_a.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/services/service_b.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/utils/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/fixtures/sample_project/utils/helpers.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/integration/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/metrics/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/slices/__init__.py +0 -0
- {archunitpython-1.1.2 → archunitpython-1.2.1}/tests/test_setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
github: [LukasNiessen]
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## [1.2.1](https://github.com/LukasNiessen/ArchUnitPython/compare/v1.2.0...v1.2.1) (2026-06-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **extract_graph:** validate AST line number before range lookup ([84c9ef4](https://github.com/LukasNiessen/ArchUnitPython/commit/84c9ef4a97333ed1fa302778725ab6d5ba891574))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Performance Improvements
|
|
10
|
+
|
|
11
|
+
* **extract_graph:** optimize file path normalization ([14b4a95](https://github.com/LukasNiessen/ArchUnitPython/commit/14b4a955576d4ee2464c8c2cceb71f28b9135198))
|
|
12
|
+
* **extract_graph:** replace linear search in `_in_type_checking()` with binary search ([1285b5e](https://github.com/LukasNiessen/ArchUnitPython/commit/1285b5e5ac513d7897d42b5e6c1fcb0bd83c1835))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Reverts
|
|
16
|
+
|
|
17
|
+
* Reverted the binary search implementation in `_in_type_checking()` function. ([d06a455](https://github.com/LukasNiessen/ArchUnitPython/commit/d06a45569fdfe5eab5e6825f6046c773b66d61c7))
|
|
18
|
+
|
|
19
|
+
# [1.2.0](https://github.com/LukasNiessen/ArchUnitPython/compare/v1.1.2...v1.2.0) (2026-06-27)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add graph reporting and sponsorship links ([6d5eabc](https://github.com/LukasNiessen/ArchUnitPython/commit/6d5eabc1c1395c5bb4cf18e222ac472d33c02eb4))
|
|
25
|
+
|
|
1
26
|
## [1.1.2](https://github.com/LukasNiessen/ArchUnitPython/compare/v1.1.1...v1.1.2) (2026-06-23)
|
|
2
27
|
|
|
3
28
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: archunitpython
|
|
3
|
-
Version: 1.1
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Architecture testing library for Python projects. Enforce dependency rules, detect cycles, validate metrics.
|
|
5
5
|
Project-URL: Homepage, https://github.com/LukasNiessen/ArchUnitPython
|
|
6
6
|
Project-URL: Repository, https://github.com/LukasNiessen/ArchUnitPython.git
|
|
@@ -39,18 +39,19 @@ Description-Content-Type: text/markdown
|
|
|
39
39
|
<!-- spacer -->
|
|
40
40
|
<p></p>
|
|
41
41
|
|
|
42
|
-
[](https://opensource.org/licenses/MIT)
|
|
43
|
-
[](https://github.com/LukasNiessen/ArchUnitPython)
|
|
42
|
+
[](https://opensource.org/licenses/MIT) [](https://github.com/LukasNiessen/ArchUnitPython/actions/workflows/integrate.yaml) [](https://github.com/LukasNiessen/ArchUnitPython)<br>
|
|
43
|
+
[](https://pepy.tech/project/archunitpython) [](https://pepy.tech/project/archunitpython)
|
|
44
|
+
<!-- [](https://pypi.org/project/archunitpython/) -->
|
|
46
45
|
|
|
47
46
|
</div>
|
|
48
47
|
|
|
49
48
|
Enforce architecture rules in Python projects. Check for dependency directions, detect circular dependencies, enforce coding standards and much more. Integrates with pytest and any other testing framework. Very simple setup and pipeline integration. Zero runtime dependencies.
|
|
50
49
|
|
|
50
|
+
The #1 ArchUnit-style architecture testing library for Python, measured by GitHub stars.
|
|
51
|
+
|
|
51
52
|
_Inspired by the amazing ArchUnit library but we are not affiliated with ArchUnit._
|
|
52
53
|
|
|
53
|
-
[Setup](#-setup) • [Use Cases](#-use-cases) • [Features](#-features) • [Contributing](CONTRIBUTING.md)
|
|
54
|
+
[Setup](#-setup) • [Use Cases](#-use-cases) • [Features](#-features) • [Why ArchUnitPython?](#-library-comparison) • [Sponsor](https://github.com/sponsors/LukasNiessen) • [Contributing](CONTRIBUTING.md)
|
|
54
55
|
|
|
55
56
|
## ⚡ 5 min Quickstart
|
|
56
57
|
|
|
@@ -121,6 +122,22 @@ These tests run automatically in your testing setup, for example in your CI pipe
|
|
|
121
122
|
run: pytest tests/test_architecture.py -v
|
|
122
123
|
```
|
|
123
124
|
|
|
125
|
+
You can also export dependency graph reports as CI artifacts:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from archunitpython import project_graph
|
|
129
|
+
|
|
130
|
+
def test_generate_dependency_graph_reports():
|
|
131
|
+
graph = project_graph("src/").titled("Application Architecture")
|
|
132
|
+
|
|
133
|
+
graph.collapse_to_folder_depth(2).export_as_html(
|
|
134
|
+
"reports/dependency-graph.html"
|
|
135
|
+
)
|
|
136
|
+
graph.export_as_mermaid("reports/dependency-graph.mmd")
|
|
137
|
+
|
|
138
|
+
assert graph.snapshot().summary.node_count >= 0
|
|
139
|
+
```
|
|
140
|
+
|
|
124
141
|
## 🚐 Setup
|
|
125
142
|
|
|
126
143
|
Installation:
|
|
@@ -165,6 +182,7 @@ from archunitpython import CheckOptions
|
|
|
165
182
|
options = CheckOptions(
|
|
166
183
|
allow_empty_tests=True, # Don't fail when no files match
|
|
167
184
|
clear_cache=True, # Clear the graph cache
|
|
185
|
+
ignore_type_checking_imports=True, # Ignore imports inside if TYPE_CHECKING
|
|
168
186
|
)
|
|
169
187
|
|
|
170
188
|
violations = rule.check(options)
|
|
@@ -228,6 +246,65 @@ def test_business_not_depend_on_presentation():
|
|
|
228
246
|
assert_passes(rule)
|
|
229
247
|
```
|
|
230
248
|
|
|
249
|
+
### Named Layer Rules
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
from archunitpython import project_layers
|
|
253
|
+
|
|
254
|
+
def test_clean_architecture_layers():
|
|
255
|
+
rule = (
|
|
256
|
+
project_layers("src/")
|
|
257
|
+
.layer("presentation").defined_by_folder("**/presentation/**")
|
|
258
|
+
.layer("business").defined_by_folder("**/business/**")
|
|
259
|
+
.layer("database").defined_by_folder("**/database/**")
|
|
260
|
+
.where_layer("presentation")
|
|
261
|
+
.may_only_depend_on_layers("business")
|
|
262
|
+
.where_layer("business")
|
|
263
|
+
.may_only_depend_on_layers()
|
|
264
|
+
.where_layer("database")
|
|
265
|
+
.may_only_depend_on_layers()
|
|
266
|
+
)
|
|
267
|
+
assert_passes(rule)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### External Dependencies
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
def test_domain_does_not_import_requests():
|
|
274
|
+
rule = (
|
|
275
|
+
project_files("src/")
|
|
276
|
+
.in_folder("**/domain/**")
|
|
277
|
+
.should_not()
|
|
278
|
+
.depend_on_external_modules()
|
|
279
|
+
.matching("requests")
|
|
280
|
+
)
|
|
281
|
+
assert_passes(rule)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### TYPE_CHECKING-aware Analysis
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
from archunitpython import CheckOptions
|
|
288
|
+
|
|
289
|
+
def test_type_only_dependencies_do_not_count_as_runtime_coupling():
|
|
290
|
+
rule = (
|
|
291
|
+
project_files("src/")
|
|
292
|
+
.in_folder("**/api/**")
|
|
293
|
+
.should_not()
|
|
294
|
+
.depend_on_files()
|
|
295
|
+
.in_folder("**/infrastructure/**")
|
|
296
|
+
)
|
|
297
|
+
assert_passes(rule, CheckOptions(ignore_type_checking_imports=True))
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Dynamic Imports and Ignore Directives
|
|
301
|
+
|
|
302
|
+
ArchUnitPython detects string-based dynamic imports such as `importlib.import_module("my_app.adapters.sql")` and `__import__("my_app.adapters.sql")`. For known migration shims, you can suppress one import edge locally:
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
from my_app.adapters.sql import Repository # archunit: ignore
|
|
306
|
+
```
|
|
307
|
+
|
|
231
308
|
### Naming Conventions
|
|
232
309
|
|
|
233
310
|
```python
|
|
@@ -350,6 +427,48 @@ def test_no_forbidden_dependency():
|
|
|
350
427
|
assert_passes(rule)
|
|
351
428
|
```
|
|
352
429
|
|
|
430
|
+
### Dependency Graph Reports
|
|
431
|
+
|
|
432
|
+
Generate dependency graph reports in multiple formats and narrow them to the part of the codebase you want to inspect.
|
|
433
|
+
|
|
434
|
+
```python
|
|
435
|
+
from archunitpython import project_graph
|
|
436
|
+
|
|
437
|
+
def test_export_dependency_graph_reports():
|
|
438
|
+
graph = project_graph("src/").titled("Application Architecture")
|
|
439
|
+
|
|
440
|
+
graph.collapse_to_folder_depth(2).export_as_mermaid(
|
|
441
|
+
"reports/dependencies.mmd"
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
graph.focus_on("**/domain/**", 1).export_as_html(
|
|
445
|
+
"reports/domain-dependencies.html"
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
assert graph.snapshot().summary.node_count >= 0
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Supported formats:
|
|
452
|
+
|
|
453
|
+
- DOT (`export_as_dot`, `to_dot`)
|
|
454
|
+
- Mermaid (`export_as_mermaid`, `to_mermaid`)
|
|
455
|
+
- D2 (`export_as_d2`, `to_d2`)
|
|
456
|
+
- CSV (`export_as_csv`, `to_csv`)
|
|
457
|
+
- JSON (`export_as_json`, `to_json`)
|
|
458
|
+
- HTML (`export_as_html`, `to_html`)
|
|
459
|
+
|
|
460
|
+
Graph exploration options:
|
|
461
|
+
|
|
462
|
+
- `focus_on(pattern, depth)` keeps matching files and their neighbors.
|
|
463
|
+
- `reachable_from(pattern)` keeps matching files and their transitive dependencies.
|
|
464
|
+
- `dependents_of(pattern)` keeps files that transitively depend on the matching files.
|
|
465
|
+
- `collapse_to_folder_depth(depth)` aggregates files to folder-level graph nodes.
|
|
466
|
+
- `collapse_by_pattern(pattern, replacement)` maps files to custom graph nodes.
|
|
467
|
+
- `include_external_dependencies()` includes imports to external modules such as `requests` or `sqlalchemy`.
|
|
468
|
+
- `include_self_dependencies()` keeps self edges that are normally hidden in reports.
|
|
469
|
+
|
|
470
|
+
When you create reports through `project_graph("src/")`, internal file paths are displayed relative to that project root so the output stays readable.
|
|
471
|
+
|
|
353
472
|
### Reports
|
|
354
473
|
|
|
355
474
|
Generate HTML reports for your metrics. _Note that this feature is in beta._
|
|
@@ -529,6 +648,40 @@ def test_from_file():
|
|
|
529
648
|
assert_passes(rule)
|
|
530
649
|
```
|
|
531
650
|
|
|
651
|
+
## 📊 Library Comparison
|
|
652
|
+
|
|
653
|
+
Here's how ArchUnitPython compares to other Python architecture-enforcement libraries.
|
|
654
|
+
|
|
655
|
+
ArchUnitPython is optimized for **architecture rules as tests**: rules live next to your normal unit tests, run in pytest/unittest/CI, and fail with test-style violation messages. Broader CLI-first tools such as [Tach](https://github.com/tach-org/tach) and [Import Linter](https://github.com/seddonym/import-linter) are excellent adjacent tools, but they solve the problem through separate configuration and commands rather than a test-native ArchUnit-style API.
|
|
656
|
+
|
|
657
|
+
| Feature | **ArchUnitPython** | **Tach** | **Import Linter** | **PyTestArch** |
|
|
658
|
+
| ------- | ------------------ | -------- | ----------------- | -------------- |
|
|
659
|
+
| **Primary workflow** | ✅ Architecture rules as unit tests | ⚠️ CLI + `tach.toml` | ⚠️ CLI + contracts config | ⚠️ pytest-oriented evaluable architecture |
|
|
660
|
+
| **ArchUnit-style fluent API** | ✅ Yes | ❌ No | ❌ No | ⚠️ Partial |
|
|
661
|
+
| **Testing framework integration** | ✅ pytest, unittest, any runner | ⚠️ CI/pre-commit CLI | ⚠️ CI/pre-commit CLI | ⚠️ pytest-focused |
|
|
662
|
+
| **Zero runtime dependencies** | ✅ Standard library only | ⚠️ No app runtime impact, Rust-backed tool | ❌ Tool dependencies | ❌ Tool dependencies |
|
|
663
|
+
| **Circular dependency detection** | ✅ First-class | ✅ First-class | ⚠️ Contract/graph based | ⚠️ Import-rule based |
|
|
664
|
+
| **File/folder dependency rules** | ✅ Glob + regex | ✅ Module config | ✅ Import contracts | ✅ Module rules |
|
|
665
|
+
| **Named layer rules** | ✅ `project_layers()` | ✅ Supported | ✅ Supported | ✅ Supported |
|
|
666
|
+
| **External dependency rules** | ✅ `depend_on_external_modules()` | ⚠️ Internal module focus | ⚠️ Import contract focus | ⚠️ Internal import focus |
|
|
667
|
+
| **TYPE_CHECKING-aware analysis** | ✅ Configurable | ⚠️ Not the core API | ⚠️ Not the core API | ⚠️ Not the core API |
|
|
668
|
+
| **Dynamic import detection** | ✅ `importlib` + `__import__` string calls | ⚠️ Not the core workflow | ⚠️ Not the core workflow | ⚠️ Import analysis focused |
|
|
669
|
+
| **Inline ignore directives** | ✅ `# archunit: ignore` | ✅ Supported | ⚠️ Config-based ignores | ⚠️ Rule/exclusion based |
|
|
670
|
+
| **Naming convention checks** | ✅ Files and paths | ❌ No | ❌ No | ⚠️ Module-name oriented |
|
|
671
|
+
| **Code metrics** | ✅ Counts, LCOM, distance metrics | ❌ No | ❌ No | ❌ No |
|
|
672
|
+
| **Custom rules and metrics** | ✅ Full support | ❌ No | ⚠️ Custom contracts | ⚠️ Limited custom rule composition |
|
|
673
|
+
| **PlantUML diagram validation** | ✅ Supported | ❌ No | ❌ No | ❌ No |
|
|
674
|
+
| **Empty test protection** | ✅ Fails by default | ⚠️ Config validation | ⚠️ Contract validation | ⚠️ Not the main focus |
|
|
675
|
+
| **Graph/reporting** | ✅ DOT, Mermaid, D2, CSV, JSON, HTML graph reports + metrics HTML | ✅ DOT, JSON, web graph | ✅ Browser UI | ⚠️ Optional graph visualization |
|
|
676
|
+
| **Best fit** | Architecture tests, CI fitness functions, metrics, diagrams | Modular monolith dependency governance | Config-driven import contracts | pytest import-boundary checks |
|
|
677
|
+
|
|
678
|
+
The most important differences:
|
|
679
|
+
|
|
680
|
+
- **Test-native by design**: ArchUnitPython rules are just Python tests, so architecture decisions are reviewed, run, and debugged in the same workflow as the rest of your test suite.
|
|
681
|
+
- **Broader rule surface**: dependency direction, cycles, layer policies, external modules, type-only imports, dynamic imports, naming, metrics, custom rules, and PlantUML validation live in one API.
|
|
682
|
+
- **False-positive protection**: empty checks fail by default, which helps catch typos in file and folder patterns before they silently make your architecture tests meaningless.
|
|
683
|
+
- **Quality beyond imports**: ArchUnitPython can enforce code metrics such as LCOM cohesion, field/method counts, abstractness, instability, and distance from the main sequence.
|
|
684
|
+
|
|
532
685
|
## 📢 Informative Error Messages
|
|
533
686
|
|
|
534
687
|
When tests fail, you get helpful output with file paths and violation details:
|
|
@@ -590,6 +743,7 @@ The features of ArchUnitPython can very well be used as architectural fitness fu
|
|
|
590
743
|
| **Files** | File and folder based rules | Stable |
|
|
591
744
|
| **Metrics** | Code quality metrics | Stable |
|
|
592
745
|
| **Slices** | Architecture slicing | Stable |
|
|
746
|
+
| **Graph** | Dependency graph reports | Experimental |
|
|
593
747
|
| **Testing** | Test framework integration | Stable |
|
|
594
748
|
| **Common** | Shared utilities | Stable |
|
|
595
749
|
| **Reports** | Generate HTML reports | Experimental |
|
|
@@ -659,6 +813,7 @@ Found a bug? Want to discuss features?
|
|
|
659
813
|
If ArchUnitPython helps your project, please consider:
|
|
660
814
|
|
|
661
815
|
- Starring the repository 💚
|
|
816
|
+
- Sponsoring development via [GitHub Sponsors](https://github.com/sponsors/LukasNiessen)
|
|
662
817
|
- Suggesting new features 💭
|
|
663
818
|
- Contributing code or documentation ⌨️
|
|
664
819
|
|
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
<!-- spacer -->
|
|
7
7
|
<p></p>
|
|
8
8
|
|
|
9
|
-
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://github.com/LukasNiessen/ArchUnitPython)
|
|
9
|
+
[](https://opensource.org/licenses/MIT) [](https://github.com/LukasNiessen/ArchUnitPython/actions/workflows/integrate.yaml) [](https://github.com/LukasNiessen/ArchUnitPython)<br>
|
|
10
|
+
[](https://pepy.tech/project/archunitpython) [](https://pepy.tech/project/archunitpython)
|
|
11
|
+
<!-- [](https://pypi.org/project/archunitpython/) -->
|
|
13
12
|
|
|
14
13
|
</div>
|
|
15
14
|
|
|
16
15
|
Enforce architecture rules in Python projects. Check for dependency directions, detect circular dependencies, enforce coding standards and much more. Integrates with pytest and any other testing framework. Very simple setup and pipeline integration. Zero runtime dependencies.
|
|
17
16
|
|
|
17
|
+
The #1 ArchUnit-style architecture testing library for Python, measured by GitHub stars.
|
|
18
|
+
|
|
18
19
|
_Inspired by the amazing ArchUnit library but we are not affiliated with ArchUnit._
|
|
19
20
|
|
|
20
|
-
[Setup](#-setup) • [Use Cases](#-use-cases) • [Features](#-features) • [Contributing](CONTRIBUTING.md)
|
|
21
|
+
[Setup](#-setup) • [Use Cases](#-use-cases) • [Features](#-features) • [Why ArchUnitPython?](#-library-comparison) • [Sponsor](https://github.com/sponsors/LukasNiessen) • [Contributing](CONTRIBUTING.md)
|
|
21
22
|
|
|
22
23
|
## ⚡ 5 min Quickstart
|
|
23
24
|
|
|
@@ -88,6 +89,22 @@ These tests run automatically in your testing setup, for example in your CI pipe
|
|
|
88
89
|
run: pytest tests/test_architecture.py -v
|
|
89
90
|
```
|
|
90
91
|
|
|
92
|
+
You can also export dependency graph reports as CI artifacts:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from archunitpython import project_graph
|
|
96
|
+
|
|
97
|
+
def test_generate_dependency_graph_reports():
|
|
98
|
+
graph = project_graph("src/").titled("Application Architecture")
|
|
99
|
+
|
|
100
|
+
graph.collapse_to_folder_depth(2).export_as_html(
|
|
101
|
+
"reports/dependency-graph.html"
|
|
102
|
+
)
|
|
103
|
+
graph.export_as_mermaid("reports/dependency-graph.mmd")
|
|
104
|
+
|
|
105
|
+
assert graph.snapshot().summary.node_count >= 0
|
|
106
|
+
```
|
|
107
|
+
|
|
91
108
|
## 🚐 Setup
|
|
92
109
|
|
|
93
110
|
Installation:
|
|
@@ -132,6 +149,7 @@ from archunitpython import CheckOptions
|
|
|
132
149
|
options = CheckOptions(
|
|
133
150
|
allow_empty_tests=True, # Don't fail when no files match
|
|
134
151
|
clear_cache=True, # Clear the graph cache
|
|
152
|
+
ignore_type_checking_imports=True, # Ignore imports inside if TYPE_CHECKING
|
|
135
153
|
)
|
|
136
154
|
|
|
137
155
|
violations = rule.check(options)
|
|
@@ -195,6 +213,65 @@ def test_business_not_depend_on_presentation():
|
|
|
195
213
|
assert_passes(rule)
|
|
196
214
|
```
|
|
197
215
|
|
|
216
|
+
### Named Layer Rules
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
from archunitpython import project_layers
|
|
220
|
+
|
|
221
|
+
def test_clean_architecture_layers():
|
|
222
|
+
rule = (
|
|
223
|
+
project_layers("src/")
|
|
224
|
+
.layer("presentation").defined_by_folder("**/presentation/**")
|
|
225
|
+
.layer("business").defined_by_folder("**/business/**")
|
|
226
|
+
.layer("database").defined_by_folder("**/database/**")
|
|
227
|
+
.where_layer("presentation")
|
|
228
|
+
.may_only_depend_on_layers("business")
|
|
229
|
+
.where_layer("business")
|
|
230
|
+
.may_only_depend_on_layers()
|
|
231
|
+
.where_layer("database")
|
|
232
|
+
.may_only_depend_on_layers()
|
|
233
|
+
)
|
|
234
|
+
assert_passes(rule)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### External Dependencies
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
def test_domain_does_not_import_requests():
|
|
241
|
+
rule = (
|
|
242
|
+
project_files("src/")
|
|
243
|
+
.in_folder("**/domain/**")
|
|
244
|
+
.should_not()
|
|
245
|
+
.depend_on_external_modules()
|
|
246
|
+
.matching("requests")
|
|
247
|
+
)
|
|
248
|
+
assert_passes(rule)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### TYPE_CHECKING-aware Analysis
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
from archunitpython import CheckOptions
|
|
255
|
+
|
|
256
|
+
def test_type_only_dependencies_do_not_count_as_runtime_coupling():
|
|
257
|
+
rule = (
|
|
258
|
+
project_files("src/")
|
|
259
|
+
.in_folder("**/api/**")
|
|
260
|
+
.should_not()
|
|
261
|
+
.depend_on_files()
|
|
262
|
+
.in_folder("**/infrastructure/**")
|
|
263
|
+
)
|
|
264
|
+
assert_passes(rule, CheckOptions(ignore_type_checking_imports=True))
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Dynamic Imports and Ignore Directives
|
|
268
|
+
|
|
269
|
+
ArchUnitPython detects string-based dynamic imports such as `importlib.import_module("my_app.adapters.sql")` and `__import__("my_app.adapters.sql")`. For known migration shims, you can suppress one import edge locally:
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
from my_app.adapters.sql import Repository # archunit: ignore
|
|
273
|
+
```
|
|
274
|
+
|
|
198
275
|
### Naming Conventions
|
|
199
276
|
|
|
200
277
|
```python
|
|
@@ -317,6 +394,48 @@ def test_no_forbidden_dependency():
|
|
|
317
394
|
assert_passes(rule)
|
|
318
395
|
```
|
|
319
396
|
|
|
397
|
+
### Dependency Graph Reports
|
|
398
|
+
|
|
399
|
+
Generate dependency graph reports in multiple formats and narrow them to the part of the codebase you want to inspect.
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
from archunitpython import project_graph
|
|
403
|
+
|
|
404
|
+
def test_export_dependency_graph_reports():
|
|
405
|
+
graph = project_graph("src/").titled("Application Architecture")
|
|
406
|
+
|
|
407
|
+
graph.collapse_to_folder_depth(2).export_as_mermaid(
|
|
408
|
+
"reports/dependencies.mmd"
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
graph.focus_on("**/domain/**", 1).export_as_html(
|
|
412
|
+
"reports/domain-dependencies.html"
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
assert graph.snapshot().summary.node_count >= 0
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Supported formats:
|
|
419
|
+
|
|
420
|
+
- DOT (`export_as_dot`, `to_dot`)
|
|
421
|
+
- Mermaid (`export_as_mermaid`, `to_mermaid`)
|
|
422
|
+
- D2 (`export_as_d2`, `to_d2`)
|
|
423
|
+
- CSV (`export_as_csv`, `to_csv`)
|
|
424
|
+
- JSON (`export_as_json`, `to_json`)
|
|
425
|
+
- HTML (`export_as_html`, `to_html`)
|
|
426
|
+
|
|
427
|
+
Graph exploration options:
|
|
428
|
+
|
|
429
|
+
- `focus_on(pattern, depth)` keeps matching files and their neighbors.
|
|
430
|
+
- `reachable_from(pattern)` keeps matching files and their transitive dependencies.
|
|
431
|
+
- `dependents_of(pattern)` keeps files that transitively depend on the matching files.
|
|
432
|
+
- `collapse_to_folder_depth(depth)` aggregates files to folder-level graph nodes.
|
|
433
|
+
- `collapse_by_pattern(pattern, replacement)` maps files to custom graph nodes.
|
|
434
|
+
- `include_external_dependencies()` includes imports to external modules such as `requests` or `sqlalchemy`.
|
|
435
|
+
- `include_self_dependencies()` keeps self edges that are normally hidden in reports.
|
|
436
|
+
|
|
437
|
+
When you create reports through `project_graph("src/")`, internal file paths are displayed relative to that project root so the output stays readable.
|
|
438
|
+
|
|
320
439
|
### Reports
|
|
321
440
|
|
|
322
441
|
Generate HTML reports for your metrics. _Note that this feature is in beta._
|
|
@@ -496,6 +615,40 @@ def test_from_file():
|
|
|
496
615
|
assert_passes(rule)
|
|
497
616
|
```
|
|
498
617
|
|
|
618
|
+
## 📊 Library Comparison
|
|
619
|
+
|
|
620
|
+
Here's how ArchUnitPython compares to other Python architecture-enforcement libraries.
|
|
621
|
+
|
|
622
|
+
ArchUnitPython is optimized for **architecture rules as tests**: rules live next to your normal unit tests, run in pytest/unittest/CI, and fail with test-style violation messages. Broader CLI-first tools such as [Tach](https://github.com/tach-org/tach) and [Import Linter](https://github.com/seddonym/import-linter) are excellent adjacent tools, but they solve the problem through separate configuration and commands rather than a test-native ArchUnit-style API.
|
|
623
|
+
|
|
624
|
+
| Feature | **ArchUnitPython** | **Tach** | **Import Linter** | **PyTestArch** |
|
|
625
|
+
| ------- | ------------------ | -------- | ----------------- | -------------- |
|
|
626
|
+
| **Primary workflow** | ✅ Architecture rules as unit tests | ⚠️ CLI + `tach.toml` | ⚠️ CLI + contracts config | ⚠️ pytest-oriented evaluable architecture |
|
|
627
|
+
| **ArchUnit-style fluent API** | ✅ Yes | ❌ No | ❌ No | ⚠️ Partial |
|
|
628
|
+
| **Testing framework integration** | ✅ pytest, unittest, any runner | ⚠️ CI/pre-commit CLI | ⚠️ CI/pre-commit CLI | ⚠️ pytest-focused |
|
|
629
|
+
| **Zero runtime dependencies** | ✅ Standard library only | ⚠️ No app runtime impact, Rust-backed tool | ❌ Tool dependencies | ❌ Tool dependencies |
|
|
630
|
+
| **Circular dependency detection** | ✅ First-class | ✅ First-class | ⚠️ Contract/graph based | ⚠️ Import-rule based |
|
|
631
|
+
| **File/folder dependency rules** | ✅ Glob + regex | ✅ Module config | ✅ Import contracts | ✅ Module rules |
|
|
632
|
+
| **Named layer rules** | ✅ `project_layers()` | ✅ Supported | ✅ Supported | ✅ Supported |
|
|
633
|
+
| **External dependency rules** | ✅ `depend_on_external_modules()` | ⚠️ Internal module focus | ⚠️ Import contract focus | ⚠️ Internal import focus |
|
|
634
|
+
| **TYPE_CHECKING-aware analysis** | ✅ Configurable | ⚠️ Not the core API | ⚠️ Not the core API | ⚠️ Not the core API |
|
|
635
|
+
| **Dynamic import detection** | ✅ `importlib` + `__import__` string calls | ⚠️ Not the core workflow | ⚠️ Not the core workflow | ⚠️ Import analysis focused |
|
|
636
|
+
| **Inline ignore directives** | ✅ `# archunit: ignore` | ✅ Supported | ⚠️ Config-based ignores | ⚠️ Rule/exclusion based |
|
|
637
|
+
| **Naming convention checks** | ✅ Files and paths | ❌ No | ❌ No | ⚠️ Module-name oriented |
|
|
638
|
+
| **Code metrics** | ✅ Counts, LCOM, distance metrics | ❌ No | ❌ No | ❌ No |
|
|
639
|
+
| **Custom rules and metrics** | ✅ Full support | ❌ No | ⚠️ Custom contracts | ⚠️ Limited custom rule composition |
|
|
640
|
+
| **PlantUML diagram validation** | ✅ Supported | ❌ No | ❌ No | ❌ No |
|
|
641
|
+
| **Empty test protection** | ✅ Fails by default | ⚠️ Config validation | ⚠️ Contract validation | ⚠️ Not the main focus |
|
|
642
|
+
| **Graph/reporting** | ✅ DOT, Mermaid, D2, CSV, JSON, HTML graph reports + metrics HTML | ✅ DOT, JSON, web graph | ✅ Browser UI | ⚠️ Optional graph visualization |
|
|
643
|
+
| **Best fit** | Architecture tests, CI fitness functions, metrics, diagrams | Modular monolith dependency governance | Config-driven import contracts | pytest import-boundary checks |
|
|
644
|
+
|
|
645
|
+
The most important differences:
|
|
646
|
+
|
|
647
|
+
- **Test-native by design**: ArchUnitPython rules are just Python tests, so architecture decisions are reviewed, run, and debugged in the same workflow as the rest of your test suite.
|
|
648
|
+
- **Broader rule surface**: dependency direction, cycles, layer policies, external modules, type-only imports, dynamic imports, naming, metrics, custom rules, and PlantUML validation live in one API.
|
|
649
|
+
- **False-positive protection**: empty checks fail by default, which helps catch typos in file and folder patterns before they silently make your architecture tests meaningless.
|
|
650
|
+
- **Quality beyond imports**: ArchUnitPython can enforce code metrics such as LCOM cohesion, field/method counts, abstractness, instability, and distance from the main sequence.
|
|
651
|
+
|
|
499
652
|
## 📢 Informative Error Messages
|
|
500
653
|
|
|
501
654
|
When tests fail, you get helpful output with file paths and violation details:
|
|
@@ -557,6 +710,7 @@ The features of ArchUnitPython can very well be used as architectural fitness fu
|
|
|
557
710
|
| **Files** | File and folder based rules | Stable |
|
|
558
711
|
| **Metrics** | Code quality metrics | Stable |
|
|
559
712
|
| **Slices** | Architecture slicing | Stable |
|
|
713
|
+
| **Graph** | Dependency graph reports | Experimental |
|
|
560
714
|
| **Testing** | Test framework integration | Stable |
|
|
561
715
|
| **Common** | Shared utilities | Stable |
|
|
562
716
|
| **Reports** | Generate HTML reports | Experimental |
|
|
@@ -626,6 +780,7 @@ Found a bug? Want to discuss features?
|
|
|
626
780
|
If ArchUnitPython helps your project, please consider:
|
|
627
781
|
|
|
628
782
|
- Starring the repository 💚
|
|
783
|
+
- Sponsoring development via [GitHub Sponsors](https://github.com/sponsors/LukasNiessen)
|
|
629
784
|
- Suggesting new features 💭
|
|
630
785
|
- Contributing code or documentation ⌨️
|
|
631
786
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "archunitpython"
|
|
7
|
-
version = "1.1
|
|
7
|
+
version = "1.2.1"
|
|
8
8
|
description = "Architecture testing library for Python projects. Enforce dependency rules, detect cycles, validate metrics."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""ArchUnitPython - Architecture testing library for Python projects."""
|
|
2
2
|
|
|
3
|
-
__version__ = "1.1
|
|
3
|
+
__version__ = "1.2.1"
|
|
4
4
|
|
|
5
5
|
# Files API
|
|
6
6
|
# Common
|
|
@@ -13,6 +13,8 @@ from archunitpython.common import (
|
|
|
13
13
|
)
|
|
14
14
|
from archunitpython.common.extraction import clear_graph_cache, extract_graph
|
|
15
15
|
from archunitpython.files import files, project_files
|
|
16
|
+
from archunitpython.graph import dependency_graph, project_graph
|
|
17
|
+
from archunitpython.layers import layers, project_layers
|
|
16
18
|
|
|
17
19
|
# Metrics API
|
|
18
20
|
from archunitpython.metrics import metrics
|
|
@@ -27,6 +29,12 @@ __all__ = [
|
|
|
27
29
|
# Files
|
|
28
30
|
"project_files",
|
|
29
31
|
"files",
|
|
32
|
+
# Graph
|
|
33
|
+
"project_graph",
|
|
34
|
+
"dependency_graph",
|
|
35
|
+
# Layers
|
|
36
|
+
"project_layers",
|
|
37
|
+
"layers",
|
|
30
38
|
# Slices
|
|
31
39
|
"project_slices",
|
|
32
40
|
# Metrics
|