diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10228f8..05177d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,4 +12,4 @@ repos: entry: poetry run poe fix language: system require_serial: true - types_or: [python, pyi, jupyter] + types: [python] diff --git a/pyproject.toml b/pyproject.toml index e80d9eb..9df2634 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,8 +98,15 @@ log_level = "DEBUG" line-length = 79 [tool.ruff.lint] -select = ["E", "F", "I"] +select = ["D", "E", "F", "I"] +ignore = ["D102", "D103", "D105", "D107", "D415"] [tool.ruff.lint.isort] force-sort-within-sections = true lines-after-imports = 2 + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.per-file-ignores] +"tests/**" = ["D"] diff --git a/src/git_draft/__init__.py b/src/git_draft/__init__.py index 1c23420..c7073f3 100644 --- a/src/git_draft/__init__.py +++ b/src/git_draft/__init__.py @@ -1,3 +1,5 @@ +"""Git-friendly code assistant""" + import logging from .bots import Action, Bot, Goal, Toolbox diff --git a/src/git_draft/__main__.py b/src/git_draft/__main__.py index 20093f2..6fa07d4 100644 --- a/src/git_draft/__main__.py +++ b/src/git_draft/__main__.py @@ -123,6 +123,8 @@ def callback(_option, _opt, _value, parser) -> None: class ToolPrinter(ToolVisitor): + """Visitor implementation which prints invocations to stdout""" + def on_list_files( self, _paths: Sequence[PurePosixPath], _reason: str | None ) -> None: diff --git a/src/git_draft/bots/common.py b/src/git_draft/bots/common.py index a85e334..2da0b81 100644 --- a/src/git_draft/bots/common.py +++ b/src/git_draft/bots/common.py @@ -1,3 +1,5 @@ +"""Shared bot utilities""" + from __future__ import annotations import dataclasses @@ -55,6 +57,7 @@ def state_folder_path(cls, ensure_exists=False) -> Path: Args: ensure_exists: Create the folder if it does not exist. + """ name = qualified_class_name(cls) path = ensure_state_home() / "bots" / name diff --git a/src/git_draft/common.py b/src/git_draft/common.py index 1ba38fe..ebf3c40 100644 --- a/src/git_draft/common.py +++ b/src/git_draft/common.py @@ -35,6 +35,8 @@ def ensure_state_home() -> Path: @dataclasses.dataclass(frozen=True) class Config: + """Overall CLI configuration""" + log_level: int = logging.INFO auto_reset: bool = True bots: Sequence[BotConfig] = dataclasses.field(default_factory=lambda: []) @@ -61,6 +63,8 @@ def load(cls) -> Self: @dataclasses.dataclass(frozen=True) class BotConfig: + """Individual bot configuration for CLI use""" + factory: str name: str | None = None config: JSONObject | None = None diff --git a/src/git_draft/drafter.py b/src/git_draft/drafter.py index bfd9660..90c05ca 100644 --- a/src/git_draft/drafter.py +++ b/src/git_draft/drafter.py @@ -1,3 +1,5 @@ +"""Git state management logic""" + from __future__ import annotations import dataclasses diff --git a/src/git_draft/prompt.py b/src/git_draft/prompt.py index 4b1cc12..fb3ed03 100644 --- a/src/git_draft/prompt.py +++ b/src/git_draft/prompt.py @@ -21,6 +21,8 @@ @dataclasses.dataclass(frozen=True) class TemplatedPrompt: + """A parametrized prompt""" + template: str context: Mapping[str, str] @@ -32,6 +34,7 @@ def parse(cls, name: str, *args: str) -> Self: name: The name of the template. *args: Additional arguments for context, expected in 'key=value' format. + """ return cls(name, dict(e.split("=", 1) for e in args)) @@ -94,6 +97,8 @@ def _extract_preamble(source: str, env: jinja2.Environment) -> str | None: @dataclasses.dataclass(frozen=True) class Template: + """An available template""" + rel_path: Path abs_path: Path source: str diff --git a/src/git_draft/store.py b/src/git_draft/store.py index 614c246..648e533 100644 --- a/src/git_draft/store.py +++ b/src/git_draft/store.py @@ -16,6 +16,8 @@ class Store: + """Lightweight sqlite wrapper""" + _name = "v1.sqlite3" def __init__(self, conn: sqlite3.Connection) -> None: @@ -48,6 +50,7 @@ def cursor(self) -> Iterator[sqlite3.Cursor]: @functools.cache def sql(name: str) -> str: + """Loads a query from its name""" path = _query_root / f"{name}.sql" with open(path) as reader: return reader.read() diff --git a/src/git_draft/toolbox.py b/src/git_draft/toolbox.py index e634668..26f2d6d 100644 --- a/src/git_draft/toolbox.py +++ b/src/git_draft/toolbox.py @@ -1,3 +1,5 @@ +"""Functionality available to bots""" + from __future__ import annotations import logging @@ -82,6 +84,8 @@ def _delete(self, path: PurePosixPath) -> bool: # pragma: no cover class ToolVisitor(Protocol): + """Tool usage hook""" + def on_list_files( self, paths: Sequence[PurePosixPath], reason: str | None ) -> None: ... # pragma: no cover