Skip to content

Commit 049489a

Browse files
committed
ai(rules[AGENTS]) Require Attributes on classes with fields
why: autodoc renders every NamedTuple and dataclass field regardless of whether it is described, so an undocumented field reaches the API docs as "Alias for field number 0" or as a bare entry. Seven such stubs are live on the published site today, and nothing in the gates catches them. what: - Require an Attributes section covering every field, with an example - Note that partial coverage still ships stubs for the rest
1 parent 3750b3e commit 049489a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ type
156156
"""
157157
```
158158

159+
**Classes with fields** — `NamedTuple`, dataclasses — document every field in
160+
an `Attributes` section:
161+
162+
```python
163+
class ConfigFileResolution(t.NamedTuple):
164+
"""Outcome of deciding which config file ``add`` should write to.
165+
166+
Attributes
167+
----------
168+
path : pathlib.Path | None
169+
Config file to write to, or ``None`` when the choice was ambiguous.
170+
"""
171+
```
172+
173+
Autodoc renders every field whether or not you describe it, so an
174+
undocumented `NamedTuple` field ships to the API docs as "Alias for field
175+
number 0" and a dataclass field ships bare. Document all of them — a class
176+
with three fields and two documented still ships a stub for the third.
177+
159178
### Doctests
160179

161180
**All functions and methods MUST have working doctests.** Doctests serve as both documentation and tests.

0 commit comments

Comments
 (0)