Skip to content

Commit 0546269

Browse files
committed
AGENTS(docs[Naming Conventions]): Add API naming conventions
why: Document standard Python community patterns for API naming what: - Add get_* prefix convention for I/O methods - Document descriptive parameter naming over _all style - Include examples of good vs bad patterns - Reference Django/pytest/Sphinx as precedent
1 parent de36b9c commit 0546269

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,41 @@ def test_sync(
190190
- For typing, use `import typing as t` and access via namespace: `t.NamedTuple`, etc.
191191
- Use `from __future__ import annotations` at the top of all Python files
192192

193+
### Naming Conventions
194+
195+
Follow Python community conventions (Django, pytest, Sphinx patterns):
196+
197+
**Method naming:**
198+
- Use `get_*` prefix for methods that perform I/O or subprocess calls (e.g., `get_remotes()`, `get_revision()`)
199+
- Use `is_*` prefix for boolean checks (e.g., `is_valid()`)
200+
- Use `has_*` prefix for existence checks (e.g., `has_remote()`)
201+
202+
**Parameter naming:**
203+
- Use descriptive names instead of underscore-prefixed built-in shadows
204+
- BAD: `_all`, `_type`, `_list` (cryptic, non-standard)
205+
- GOOD: `all_remotes`, `include_all`, `file_type`, `path_list` (self-documenting)
206+
207+
**Examples:**
208+
```python
209+
# BAD - cryptic underscore prefix
210+
def fetch(_all: bool = False): ...
211+
def rev_list(_all: bool = False): ...
212+
213+
# GOOD - descriptive parameter names
214+
def fetch(all_remotes: bool = False): ...
215+
def rev_list(include_all: bool = False): ...
216+
217+
# BAD - inconsistent getter naming
218+
def remotes(): ... # No prefix
219+
def get_revision(): ... # Has prefix
220+
221+
# GOOD - consistent getter naming for subprocess calls
222+
def get_remotes(): ...
223+
def get_revision(): ...
224+
```
225+
226+
**Rationale:** Major Python projects (Django, pytest, Sphinx) don't use `_all` style prefixes. They either use the built-in name directly as a keyword-only argument, or use descriptive alternatives. Underscore prefixes are reserved for private/internal parameters only.
227+
193228
### Docstrings
194229

195230
Follow NumPy docstring style for all functions and methods:

0 commit comments

Comments
 (0)