In short
In Python many things are marked with decorators (@dataclass, @app.route, @inject). Today rules can only match by path or name; this lets a rule target decorated things — e.g. 'everything with @app.route lives in the api folder', or 'no attribute may use the field-injection decorator.'
Problem
Many rules target decorated elements — 'route handlers live in the api layer', 'no attribute uses a field-injection decorator', '@DataClass models belong to the domain'. ArchUnitPython matches on paths and names but cannot assert on decorators today.
Proposal
Add decorator/metaclass predicates onto the existing project_files(...) chain, e.g. project_files("src/").with_decorator("app.route").should().be_in_folder("**/api/**") and project_files("src/").in_folder("**/domain/**").should_not().use_decorator("inject").
Acceptance criteria
In short
In Python many things are marked with decorators (
@dataclass,@app.route,@inject). Today rules can only match by path or name; this lets a rule target decorated things — e.g. 'everything with@app.routelives in the api folder', or 'no attribute may use the field-injection decorator.'Problem
Many rules target decorated elements — 'route handlers live in the api layer', 'no attribute uses a field-injection decorator', '@DataClass models belong to the domain'. ArchUnitPython matches on paths and names but cannot assert on decorators today.
Proposal
Add decorator/metaclass predicates onto the existing
project_files(...)chain, e.g.project_files("src/").with_decorator("app.route").should().be_in_folder("**/api/**")andproject_files("src/").in_folder("**/domain/**").should_not().use_decorator("inject").Acceptance criteria
.with_decorator("dataclass")selects classes carrying that decorator, including via a meta-decorator..should_not().use_decorator("inject")fails on a violating element with a clickable location.