archetype-py 0.2.2__tar.gz → 0.2.3__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.
Files changed (78) hide show
  1. archetype_py-0.2.3/.github/ISSUE_TEMPLATE/bug_report.md +63 -0
  2. archetype_py-0.2.3/.github/ISSUE_TEMPLATE/feature_request.md +40 -0
  3. {archetype_py-0.2.2 → archetype_py-0.2.3}/.gitignore +2 -0
  4. {archetype_py-0.2.2 → archetype_py-0.2.3}/CHANGELOG.md +25 -0
  5. archetype_py-0.2.3/CODE_OF_CONDUCT.md +128 -0
  6. archetype_py-0.2.3/PKG-INFO +345 -0
  7. archetype_py-0.2.3/README.md +321 -0
  8. archetype_py-0.2.3/archetype/analysis/cache.py +95 -0
  9. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/analysis/imports.py +35 -5
  10. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/analysis/models.py +1 -0
  11. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/check.py +44 -4
  12. archetype_py-0.2.3/archetype/dsl/query.py +222 -0
  13. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/init.py +56 -1
  14. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/plugin/pytest_plugin.py +2 -0
  15. archetype_py-0.2.3/archetype/reporter.py +294 -0
  16. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/rule.py +9 -0
  17. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/rules/boundaries.py +10 -2
  18. archetype_py-0.2.3/assets/Pytest.png +0 -0
  19. archetype_py-0.2.3/assets/Rule_Execution_Flow.png +0 -0
  20. archetype_py-0.2.3/assets/Violation_Lifecycle.png +0 -0
  21. archetype_py-0.2.3/assets/architecture.png +0 -0
  22. archetype_py-0.2.3/assets/ci_integration.png +0 -0
  23. {archetype_py-0.2.2 → archetype_py-0.2.3}/pyproject.toml +1 -1
  24. archetype_py-0.2.3/tests/fixtures/simple_project/.gitignore +1 -0
  25. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_cli.py +300 -5
  26. archetype_py-0.2.3/tests/test_dsl.py +154 -0
  27. archetype_py-0.2.3/tests/test_graph.py +210 -0
  28. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_init.py +204 -0
  29. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_plugin.py +28 -0
  30. archetype_py-0.2.3/tests/test_reporter.py +136 -0
  31. archetype_py-0.2.2/PKG-INFO +0 -226
  32. archetype_py-0.2.2/README.md +0 -202
  33. archetype_py-0.2.2/archetype/dsl/query.py +0 -122
  34. archetype_py-0.2.2/archetype/reporter.py +0 -155
  35. archetype_py-0.2.2/tests/test_dsl.py +0 -84
  36. archetype_py-0.2.2/tests/test_graph.py +0 -35
  37. {archetype_py-0.2.2 → archetype_py-0.2.3}/.github/pull_request_template.md +0 -0
  38. {archetype_py-0.2.2 → archetype_py-0.2.3}/.github/workflows/archetype.yml +0 -0
  39. {archetype_py-0.2.2 → archetype_py-0.2.3}/.github/workflows/ci.yml +0 -0
  40. {archetype_py-0.2.2 → archetype_py-0.2.3}/.github/workflows/publish.yml +0 -0
  41. {archetype_py-0.2.2 → archetype_py-0.2.3}/BENCHMARKS.md +0 -0
  42. {archetype_py-0.2.2 → archetype_py-0.2.3}/CONTRIBUTING.md +0 -0
  43. {archetype_py-0.2.2 → archetype_py-0.2.3}/LICENSE +0 -0
  44. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/__init__.py +0 -0
  45. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/analysis/__init__.py +0 -0
  46. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/analysis/ast_utils.py +0 -0
  47. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/analysis/git_utils.py +0 -0
  48. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/analysis/init.py +0 -0
  49. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/analysis/pattern.py +0 -0
  50. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/dsl/__init__.py +0 -0
  51. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/dsl/init.py +0 -0
  52. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/plugin/__init__.py +0 -0
  53. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/plugin/init.py +0 -0
  54. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/rules/__init__.py +0 -0
  55. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/rules/cycles.py +0 -0
  56. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/rules/layers.py +0 -0
  57. {archetype_py-0.2.2 → archetype_py-0.2.3}/archetype/rules/naming.py +0 -0
  58. {archetype_py-0.2.2 → archetype_py-0.2.3}/architecture.py +0 -0
  59. {archetype_py-0.2.2 → archetype_py-0.2.3}/assets/logo.png +0 -0
  60. {archetype_py-0.2.2 → archetype_py-0.2.3}/benchmarks/README.md +0 -0
  61. {archetype_py-0.2.2 → archetype_py-0.2.3}/benchmarks/fixtures.py +0 -0
  62. {archetype_py-0.2.2 → archetype_py-0.2.3}/benchmarks/init.py +0 -0
  63. {archetype_py-0.2.2 → archetype_py-0.2.3}/benchmarks/run_benchmarks.py +0 -0
  64. {archetype_py-0.2.2 → archetype_py-0.2.3}/benchmarks/test_performance_regression.py +0 -0
  65. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/fixtures/simple_project/simple_project/api.py +0 -0
  66. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/fixtures/simple_project/simple_project/db.py +0 -0
  67. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/fixtures/simple_project/simple_project/internal/init.py +0 -0
  68. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/fixtures/simple_project/simple_project/internal/tokens.py +0 -0
  69. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/fixtures/simple_project/simple_project/main.py +0 -0
  70. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/fixtures/simple_project/simple_project/services.py +0 -0
  71. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_decorator_since.py +0 -0
  72. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_grouping.py +0 -0
  73. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_pattern.py +0 -0
  74. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_rule.py +0 -0
  75. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_rules_boundaries.py +0 -0
  76. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_rules_cycles.py +0 -0
  77. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_rules_layers.py +0 -0
  78. {archetype_py-0.2.2 → archetype_py-0.2.3}/tests/test_rules_naming.py +0 -0
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report a problem or unexpected behavior in archetype-py
4
+ title: "[Bug]: "
5
+ labels: bug
6
+ assignees: ''
7
+ ---
8
+
9
+ ## Description
10
+
11
+ Describe the issue clearly and concisely.
12
+
13
+ ---
14
+
15
+ ## Expected Behavior
16
+
17
+ What did you expect to happen?
18
+
19
+ ---
20
+
21
+ ## Actual Behavior
22
+
23
+ What actually happened?
24
+
25
+ ---
26
+
27
+ ## Reproduction
28
+
29
+ Steps to reproduce:
30
+
31
+ 1. Create rule:
32
+ 2. Run command:
33
+ 3. Observe output:
34
+
35
+ ---
36
+
37
+ ## Example Rule / Config
38
+
39
+ ```python
40
+ # Paste architecture.py snippet here
41
+ ```
42
+
43
+ ---
44
+
45
+ ## CLI Output
46
+
47
+ ```text
48
+ Paste error output here
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Environment
54
+
55
+ - archetype-py version:
56
+ - Python version:
57
+ - OS:
58
+
59
+ ---
60
+
61
+ ## Additional Context
62
+
63
+ Add any other context, screenshots, or examples here.
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea or improvement for archetype-py
4
+ title: "[Feature]: "
5
+ labels: enhancement
6
+ assignees: ''
7
+ ---
8
+
9
+ ## Problem
10
+
11
+ Describe the problem or limitation you're facing.
12
+
13
+ Example:
14
+ "I want to enforce boundaries between domains automatically."
15
+
16
+ ---
17
+
18
+ ## Proposed Solution
19
+
20
+ Describe the behavior or feature you'd like to see.
21
+
22
+ ---
23
+
24
+ ## Example API
25
+
26
+ ```python
27
+ # Optional example usage
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Alternatives Considered
33
+
34
+ Describe any alternatives or workarounds you've tried.
35
+
36
+ ---
37
+
38
+ ## Additional Context
39
+
40
+ Add screenshots, architecture examples, or related tools if relevant.
@@ -32,8 +32,10 @@ htmlcov/
32
32
 
33
33
  # OS files
34
34
  .DS_Store
35
+ **/.DS_Store
35
36
 
36
37
  # Hatch
37
38
  .hatch/
38
39
  LAUNCH.md
39
40
  ROADMAP.md
41
+ .archetype_cache
@@ -43,3 +43,28 @@
43
43
  - Summary line now includes warned and skipped counts
44
44
  - Reporter output organized by group when rules use group context manager
45
45
  - pytest plugin node IDs include group name when present
46
+
47
+
48
+ ## 0.2.3 — 2026-05-16
49
+
50
+ ### Added
51
+ - @warn decorator for non-blocking rule violations
52
+ - @skip decorator to temporarily disable rules
53
+ - @since decorator for date-scoped enforcement
54
+ - @rule timeout parameter for pathological graphs
55
+ - Glob pattern support in module matching
56
+ - Rule grouping with group context manager
57
+ - archetype init command for scaffolding
58
+ - --quiet flag to show only failures and warnings
59
+ - --format json flag for machine-readable output
60
+ - --no-cache flag to force fresh graph rebuild
61
+ - --group flag to run specific rule groups only
62
+ - must_not_depend_on for transitive dependency checking
63
+ - Import graph caching for faster repeat runs
64
+ - File path and line number in violation messages
65
+
66
+ ### Fixed
67
+ - src layout detection in archetype init
68
+ - Verbose violation messages now concise and scannable
69
+ - --quiet flag correctly filters JSON output
70
+ - Naming convention violation message format cleaned up
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ .
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
@@ -0,0 +1,345 @@
1
+ Metadata-Version: 2.4
2
+ Name: archetype-py
3
+ Version: 0.2.3
4
+ Summary: Enforce architectural rules as code. Catch structural violations before they merge.
5
+ Project-URL: Homepage, https://github.com/MossabArektout/archetype-py
6
+ Project-URL: Documentation, https://github.com/MossabArektout/archetype-py
7
+ Author-email: Mossab Arektout <mossabarektout2000@gmail.com>
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: click
17
+ Requires-Dist: networkx
18
+ Requires-Dist: rich
19
+ Provides-Extra: benchmarks
20
+ Provides-Extra: dev
21
+ Requires-Dist: hatch; extra == 'dev'
22
+ Requires-Dist: pytest; extra == 'dev'
23
+ Description-Content-Type: text/markdown
24
+
25
+ [![PyPI version](https://img.shields.io/pypi/v/archetype-py)](https://pypi.org/project/archetype-py/)
26
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)](https://pypi.org/project/archetype-py/)
27
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/MossabArektout/archetype-py/blob/main/LICENSE)
28
+ [![CI](https://img.shields.io/github/actions/workflow/status/MossabArektout/archetype-py/ci.yml?branch=main&label=ci)](https://github.com/MossabArektout/archetype-py/actions/workflows/ci.yml)
29
+
30
+ # archetype-py
31
+
32
+ ## Table of Contents
33
+
34
+ - [Overview](#overview)
35
+ - [archetype-py Logo](#archetype-py-logo)
36
+ - [Architecture Visuals](#architecture-visuals)
37
+ - [Why Developers Use archetype-py](#why-developers-use-archetype-py)
38
+ - [See It In Action](#see-it-in-action)
39
+ - [Quick Start](#quick-start)
40
+ - [Minimum `architecture.py` Example](#minimum-architecturepy-example)
41
+ - [Features](#features)
42
+ - [Decorators and Commands](#decorators-and-commands)
43
+ - [Perfect For](#perfect-for)
44
+ - [Installation](#installation)
45
+ - [Build & Test](#build--test)
46
+ - [Exit Codes](#exit-codes)
47
+ - [Troubleshooting](#troubleshooting)
48
+ - [Roadmap](#roadmap)
49
+ - [Contributing](#contributing)
50
+ - [Support The Project](#support-the-project)
51
+
52
+ ## Overview
53
+
54
+ archetype-py is a Python architecture testing library that helps teams define structural rules as code and enforce them continuously. Instead of relying on conventions alone, you can codify boundaries such as layer direction, forbidden dependencies, module visibility, and cycle prevention, then run those checks locally, in CI, and in pytest. This keeps architecture decisions explicit, reviewable, and resilient as the codebase grows.
55
+
56
+ ## archetype-py Logo
57
+
58
+ <p align="center">
59
+ <img src="https://raw.githubusercontent.com/MossabArektout/archetype-py/main/assets/logo.png" alt="archetype-py logo" width="280"/>
60
+ </p>
61
+
62
+ ## Architecture Visuals
63
+
64
+ ### Architecture Diagram
65
+ archetype-py lets teams define architecture rules like:
66
+
67
+ - “API must not depend on infrastructure”
68
+ - “No cycles between services”
69
+ - “Only repositories can access the database”
70
+
71
+ …and automatically enforce them in CI, locally, and in pytest.
72
+
73
+ <p align="center">
74
+ <img src="./assets/architecture.png" alt="archetype-py high-level architecture diagram" width="900"/>
75
+ </p>
76
+
77
+ ### Rule Execution Flow
78
+
79
+ <p align="center">
80
+ <img src="./assets/Rule_Execution_Flow.png" alt="archetype-py rule execution flow diagram" width="900"/>
81
+ </p>
82
+
83
+
84
+ ### Violation Lifecycle
85
+
86
+ <p align="center">
87
+ <img src="./assets/Violation_Lifecycle.png" alt="archetype-py violation lifecycle diagram" width="900"/>
88
+ </p>
89
+
90
+ ### CLI + CI Diagram
91
+
92
+ <p align="center">
93
+ <img src="./assets/ci_integration.png" alt="archetype-py CLI and CI integration diagram" width="900"/>
94
+ </p>
95
+
96
+ ### pytest Integration
97
+
98
+ <p align="center">
99
+ <img src="./assets/Pytest.png" alt="archetype-py pytest integration diagram" width="900"/>
100
+ </p>
101
+
102
+ ---
103
+
104
+ ## Why Developers Use archetype-py
105
+
106
+ Most Python tooling checks:
107
+
108
+ - formatting
109
+ - typing
110
+ - linting
111
+ - correctness
112
+
113
+ But almost nothing protects **system structure**.
114
+
115
+ As projects grow, architecture drifts silently:
116
+ - layers start leaking
117
+ - imports become tangled
118
+ - boundaries disappear
119
+ - coupling spreads
120
+
121
+ archetype-py turns architectural intent into executable checks.
122
+
123
+ ---
124
+
125
+ ## See It In Action
126
+
127
+ ### Define architecture rules
128
+
129
+ ```python
130
+ from archetype import rule
131
+ from archetype.rules import layers
132
+
133
+ @rule("layers are ordered")
134
+ def layer_order() -> None:
135
+ layers(["myapp.api", "myapp.services", "myapp.db"]).are_ordered()
136
+ ```
137
+
138
+ ### Run checks
139
+
140
+ ```bash
141
+ archetype check .
142
+ ```
143
+
144
+ ### Get actionable feedback
145
+
146
+ ```text
147
+ ✖ API cannot depend on DB internals
148
+
149
+ app.api.users
150
+ └── imports app.db.internal.session
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Quick Start
156
+
157
+ ### 1. Install
158
+
159
+ ```bash
160
+ pip install archetype-py
161
+ ```
162
+
163
+ ### 2. Generate a starter architecture file
164
+
165
+ ```bash
166
+ archetype init .
167
+ ```
168
+
169
+ ### 3. Define your rules
170
+
171
+ Edit:
172
+
173
+ ```text
174
+ architecture.py
175
+ ```
176
+
177
+ ### 4. Run checks
178
+
179
+ ```bash
180
+ archetype check .
181
+ ```
182
+
183
+ ### 5. Add to CI
184
+
185
+ ```yaml
186
+ - run: archetype check .
187
+ ```
188
+
189
+ Done.
190
+
191
+ ---
192
+
193
+ ## Minimum `architecture.py` Example
194
+
195
+ Use this as a starting point when creating or refining your rules file:
196
+
197
+ ```python
198
+ from archetype import group, imports, rule, since, warn
199
+ from archetype.rules import no_cycles
200
+
201
+ with group("Layer boundaries"):
202
+ @rule("api-must-not-import-db")
203
+ def api_must_not_import_db() -> None:
204
+ imports("myapp.api").must_not_import("myapp.db")
205
+
206
+ @rule("db-warning-example")
207
+ @warn
208
+ def db_warning_example() -> None:
209
+ imports("myapp.services").must_not_import("myapp.db.internal")
210
+
211
+ @rule("recent-violations-only")
212
+ @since("2026-01-01")
213
+ def recent_violations_only() -> None:
214
+ imports("myapp.api").must_not_import("myapp.legacy")
215
+
216
+ @rule("no-import-cycles")
217
+ def no_import_cycles() -> None:
218
+ no_cycles("myapp")
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Features
224
+
225
+ ### Architecture Rules
226
+ - Forbidden imports
227
+ - Allowlisted imports
228
+ - Layer enforcement
229
+ - Import cycle detection
230
+ - Protected module boundaries
231
+
232
+ ### Workflow Features
233
+ - Rule grouping
234
+ - Warning-level rules
235
+ - Temporary rule skips with context
236
+ - Changed-file enforcement (`since`)
237
+ - Pytest integration
238
+ - CI-friendly exit codes
239
+
240
+ ## Decorators and Commands
241
+
242
+ Rules are written in `architecture.py` with decorators. Below are all decorator-style rule helpers currently available in this library.
243
+
244
+ | Decorator / Helper | Purpose | Example |
245
+ |---|---|---|
246
+ | `@rule("name")` | Registers a rule with a human-readable display name. | `@rule("api-not-db")` |
247
+ | `@warn` | Marks a rule as warning-only (does not fail exit code). | `@warn` |
248
+ | `@skip` / `@skip(reason="...")` | Temporarily skips a rule, optionally with a reason shown in output. | `@skip(reason="Refactor in progress")` |
249
+ | `@since("YYYY-MM-DD")` | Limits violations to files changed since a specific date. | `@since("2026-01-01")` |
250
+ | `group("name")` | Context manager that assigns a group to enclosed rules (used with `--group`). | `with group("Layer boundaries"):` |
251
+
252
+ Decorator order tip: place `@rule(...)` first, then wrappers like `@warn`, `@skip`, or `@since`.
253
+
254
+ | Command | Description | Example |
255
+ |---|---|---|
256
+ | `archetype init [path]` | Detects project structure and generates a starter `architecture.py` file. | `archetype init .` |
257
+ | `archetype check [path]` | Loads `architecture.py` and runs all registered architecture rules. | `archetype check .` |
258
+ | `archetype check [path] --group <name>` | Runs only rules that belong to the specified group. | `archetype check . --group core` |
259
+
260
+
261
+
262
+ ## Perfect For
263
+
264
+ - Growing Python monoliths
265
+ - Modular backends
266
+ - Clean Architecture projects
267
+ - Hexagonal Architecture
268
+ - Domain-driven design
269
+ - Teams scaling beyond “tribal knowledge”
270
+
271
+ ---
272
+
273
+ ## Installation
274
+
275
+ ```bash
276
+ pip install archetype-py
277
+ ```
278
+
279
+ Requires Python 3.11+.
280
+
281
+ ---
282
+
283
+ ## Build & Test
284
+
285
+ For local development, install dev dependencies, run the test suite, and run architecture checks before opening a PR.
286
+
287
+ ```bash
288
+ pip install -e ".[dev]"
289
+ pytest
290
+ archetype check .
291
+ ```
292
+
293
+
294
+ ---
295
+
296
+ ## Exit Codes
297
+
298
+ - `0`: no blocking failures (passes and warnings only)
299
+ - `1`: one or more blocking rule failures
300
+
301
+ ---
302
+
303
+ ## Troubleshooting
304
+
305
+ - `Error: architecture.py not found`: run `archetype init .` in your project root, or pass the correct path to `archetype check <path>`.
306
+ - Rules seem to do nothing: confirm your rules are decorated with `@rule("...")`; undecorated functions are not registered.
307
+ - `@since(...)` behavior is unexpected: verify the date format is `YYYY-MM-DD` and that your git history is available in the checked path.
308
+ - Import path mismatches: use fully qualified module paths (`myapp.api`, not file paths like `src/api.py`).
309
+
310
+ ---
311
+
312
+ ## Roadmap
313
+
314
+ Planned improvements include:
315
+ - Graph visualization
316
+ - Architecture diffing
317
+ - IDE integrations
318
+ - Rich HTML reports
319
+ - More built-in rule primitives
320
+
321
+ ---
322
+
323
+ ## Contributing
324
+
325
+ Contributions are welcome:
326
+ - bug fixes
327
+ - rule ideas
328
+ - docs improvements
329
+ - integrations
330
+ - performance work
331
+
332
+ See [CONTRIBUTING.md](./CONTRIBUTING.md).
333
+
334
+ ---
335
+
336
+ ## Support The Project
337
+
338
+ If archetype-py helps your team:
339
+
340
+ ⭐ Star the repository
341
+ 🐛 Open issues
342
+ 🧠 Share feedback
343
+ 🔧 Contribute improvements
344
+
345
+ Every star genuinely helps the project grow.