Skip to content

Commit b51510a

Browse files
Add usethis-python-ruff agent skill (#1522)
* Initial plan * Add usethis-python-ruff agent skill for Ruff rule compliance Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com> Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/75a53981-9a0f-4b19-9ad3-2481185891cd --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
1 parent 0810f2b commit b51510a

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

  • .agents/skills/usethis-python-ruff
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: usethis-python-ruff
3+
description: Guidelines for complying with Ruff linter rules instead of suppressing them
4+
compatibility: usethis, Python, Ruff
5+
license: MIT
6+
metadata:
7+
version: "1.0"
8+
---
9+
10+
# Ruff Rule Compliance
11+
12+
When Ruff flags a violation, the default response should be to **fix the code**, not suppress the warning. Only suppress a rule as a last resort.
13+
14+
## Procedure
15+
16+
1. When a Ruff violation appears, first try to auto-fix it by running:
17+
18+
```bash
19+
uv run ruff check --fix --unsafe-fixes
20+
```
21+
22+
2. If auto-fix doesn't resolve it, manually update the code to comply with the rule.
23+
3. Only if the rule genuinely cannot be satisfied should you add a `# noqa` comment — and if you do, you **must** include an explanatory comment justifying why.
24+
4. Before adding any `# noqa`, check whether the rule code is in the never-suppress list below. If it is, you must find a way to comply.
25+
26+
## Rules that must never be suppressed
27+
28+
The following rule codes must **never** be suppressed with `# noqa`. Always fix the code to comply:
29+
30+
- **`TC`** (flake8-type-checking rules, e.g. `TC001`, `TC002`, `TC003`): Move imports into or out of `TYPE_CHECKING` blocks as the rule requires. The `--fix --unsafe-fixes` command can often resolve these automatically.
31+
32+
## When `# noqa` is acceptable
33+
34+
A `# noqa` comment is acceptable only when **all** of the following are true:
35+
36+
- Auto-fix (`--fix --unsafe-fixes`) does not resolve the violation.
37+
- Manually rewriting the code to comply is not feasible or would make the code significantly worse.
38+
- The rule code is **not** in the never-suppress list above.
39+
40+
When you do add a `# noqa`, always place a comment on the same line or adjacent line explaining **why** the suppression is necessary. A bare `# noqa: XXXX` without justification is not acceptable.

0 commit comments

Comments
 (0)