Code Style¶
Formatting and linting¶
libvcs uses ruff for formatting and linting in a
single tool. The full rule set is declared in pyproject.toml under
[tool.ruff].
$ uv run ruff format .
$ uv run ruff check . --fix --show-fixes
Type checking¶
mypy runs in strict mode:
$ uv run mypy src tests
Docstrings¶
All public APIs use NumPy-style docstrings:
def fetch(url: str, *, branch: str | None = None) -> str:
"""Fetch a remote branch.
Parameters
----------
url : str
Repository URL.
branch : str or None
Branch name. ``None`` means the default branch.
Returns
-------
str
The fetched commit hash.
"""
Imports¶
from __future__ import annotationsat the top of every file.Standard-library modules use namespace imports:
import pathlib, notfrom pathlib import Path.Typing:
import typing as t, thent.Optional,t.Any, etc.