Skip to content

Commit 5425095

Browse files
1362 create import linter skill (#1364)
* Create an Import Linter skill * Declare missing compatibility decs in the `usethis-qa-static-checks` skill
1 parent 8152857 commit 5425095

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
name: usethis-qa-import-linter
3+
description: Use the Import Linter software on the usethis project
4+
compatibility: usethis, Python, import-linter
5+
license: MIT
6+
metadata:
7+
version: "1.0"
8+
---
9+
10+
# Import Linter
11+
12+
## About
13+
14+
Import Linter is a static analysis tool to enforce a self-imposed architecture on imports. It allows you to define rules about how different parts of your codebase can import each other, helping to maintain a clean and organized code structure.
15+
16+
## Usage
17+
18+
```bash
19+
uv run lint-imports
20+
```
21+
22+
## Configuration File
23+
24+
This project uses the `.importlinter` INI file to configure Import Linter. You specify _contracts_ which need to be complied with between modules' imports. For the `usethis` project, we mainly use the `layers` contract: earlier listed "higher" layers are not allowed to import from any "lower" layers.
25+
26+
### Example Structure
27+
28+
Where `xyz` is the name of the root package (i.e. `usethis` for this project):
29+
30+
```ini
31+
[importlinter]
32+
root_packages =
33+
xyz
34+
35+
[importlinter:contract:xyz]
36+
name = xyz
37+
type = layers
38+
containers =
39+
xyz
40+
layers =
41+
ui
42+
backend
43+
domain
44+
exhaustive = true
45+
46+
[importlinter:contract:core_submodule]
47+
name = xyz.core.submodule
48+
type = layers
49+
containers =
50+
xyz.core.submodule
51+
layers =
52+
layer1
53+
layer2
54+
exhaustive = true
55+
```
56+
57+
## Procedure
58+
59+
1. Ensure the module structure complies with the Import Linter configuration.
60+
2. Explicitly add/rename new/modified modules to their parent-level contract (to adhere to the `exhaustive` setting).
61+
3. For major refactorings, rationalize the module structure and update the Import Linter configuration accordingly.
62+
4. Run Import Linter to verify that all contracts are satisfied.

.agents/skills/usethis-qa-static-checks/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
name: usethis-qa-static-checks
33
description: Perform static code checks
4-
compatibility: prek, basedpyright
4+
compatibility: usethis, Python, prek, basedpyright
55
license: MIT
66
metadata:
7-
version: "1.0"
7+
version: "1.1"
88
---
99

1010
# Static Checks

0 commit comments

Comments
 (0)