Skip to content

Commit 366d918

Browse files
authored
docs: add docstrings (#55)
1 parent 19443df commit 366d918

File tree

10 files changed

+34
-2
lines changed

10 files changed

+34
-2
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ repos:
1212
entry: poetry run poe fix
1313
language: system
1414
require_serial: true
15-
types_or: [python, pyi, jupyter]
15+
types: [python]

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,15 @@ log_level = "DEBUG"
9898
line-length = 79
9999

100100
[tool.ruff.lint]
101-
select = ["E", "F", "I"]
101+
select = ["D", "E", "F", "I"]
102+
ignore = ["D102", "D103", "D105", "D107", "D415"]
102103

103104
[tool.ruff.lint.isort]
104105
force-sort-within-sections = true
105106
lines-after-imports = 2
107+
108+
[tool.ruff.lint.pydocstyle]
109+
convention = "google"
110+
111+
[tool.ruff.lint.per-file-ignores]
112+
"tests/**" = ["D"]

src/git_draft/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Git-friendly code assistant"""
2+
13
import logging
24

35
from .bots import Action, Bot, Goal, Toolbox

src/git_draft/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def callback(_option, _opt, _value, parser) -> None:
123123

124124

125125
class ToolPrinter(ToolVisitor):
126+
"""Visitor implementation which prints invocations to stdout"""
127+
126128
def on_list_files(
127129
self, _paths: Sequence[PurePosixPath], _reason: str | None
128130
) -> None:

src/git_draft/bots/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Shared bot utilities"""
2+
13
from __future__ import annotations
24

35
import dataclasses
@@ -55,6 +57,7 @@ def state_folder_path(cls, ensure_exists=False) -> Path:
5557
5658
Args:
5759
ensure_exists: Create the folder if it does not exist.
60+
5861
"""
5962
name = qualified_class_name(cls)
6063
path = ensure_state_home() / "bots" / name

src/git_draft/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def ensure_state_home() -> Path:
3535

3636
@dataclasses.dataclass(frozen=True)
3737
class Config:
38+
"""Overall CLI configuration"""
39+
3840
log_level: int = logging.INFO
3941
auto_reset: bool = True
4042
bots: Sequence[BotConfig] = dataclasses.field(default_factory=lambda: [])
@@ -61,6 +63,8 @@ def load(cls) -> Self:
6163

6264
@dataclasses.dataclass(frozen=True)
6365
class BotConfig:
66+
"""Individual bot configuration for CLI use"""
67+
6468
factory: str
6569
name: str | None = None
6670
config: JSONObject | None = None

src/git_draft/drafter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Git state management logic"""
2+
13
from __future__ import annotations
24

35
import dataclasses

src/git_draft/prompt.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
@dataclasses.dataclass(frozen=True)
2323
class TemplatedPrompt:
24+
"""A parametrized prompt"""
25+
2426
template: str
2527
context: Mapping[str, str]
2628

@@ -32,6 +34,7 @@ def parse(cls, name: str, *args: str) -> Self:
3234
name: The name of the template.
3335
*args: Additional arguments for context, expected in 'key=value'
3436
format.
37+
3538
"""
3639
return cls(name, dict(e.split("=", 1) for e in args))
3740

@@ -94,6 +97,8 @@ def _extract_preamble(source: str, env: jinja2.Environment) -> str | None:
9497

9598
@dataclasses.dataclass(frozen=True)
9699
class Template:
100+
"""An available template"""
101+
97102
rel_path: Path
98103
abs_path: Path
99104
source: str

src/git_draft/store.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717

1818
class Store:
19+
"""Lightweight sqlite wrapper"""
20+
1921
_name = "v1.sqlite3"
2022

2123
def __init__(self, conn: sqlite3.Connection) -> None:
@@ -48,6 +50,7 @@ def cursor(self) -> Iterator[sqlite3.Cursor]:
4850

4951
@functools.cache
5052
def sql(name: str) -> str:
53+
"""Loads a query from its name"""
5154
path = _query_root / f"{name}.sql"
5255
with open(path) as reader:
5356
return reader.read()

src/git_draft/toolbox.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Functionality available to bots"""
2+
13
from __future__ import annotations
24

35
import logging
@@ -82,6 +84,8 @@ def _delete(self, path: PurePosixPath) -> bool: # pragma: no cover
8284

8385

8486
class ToolVisitor(Protocol):
87+
"""Tool usage hook"""
88+
8589
def on_list_files(
8690
self, paths: Sequence[PurePosixPath], reason: str | None
8791
) -> None: ... # pragma: no cover

0 commit comments

Comments
 (0)