vprusso/toqito

docs: add missing Raises: sections to function docstrings

Chiusa

#1888 aperta il 25 lug 2026

 (1 commento) (0 reazioni) (0 assegnatari)Python (154 fork)github user discovery
documentationgood first issue

Metriche repository

Star
 (277 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Many functions raise ValueError/TypeError on bad input but do not document it in a Raises: docstring section. Adding these sections makes the API self-documenting and surfaces the conditions in the rendered docs.

What to do

For a function that raises but has no Raises: section, add one listing each exception and the condition that triggers it, in the Google style used elsewhere in the codebase:

    Raises:
        ValueError: If `dim` does not evenly divide the input.

Good targets (pick a few per PR):

  • toqito/channel_ops/kraus_to_choi.py
  • toqito/channel_props/channel_dim.py
  • toqito/channels/amplitude_damping.py, bitflip.py, phase_damping.py, ldot_channel.py
  • toqito/matrices/cyclic_permutation.py

List each raise and its condition with:

git grep -nE "raise (Value|Type)Error" toqito/<file>

Verifying

uv sync --group docs
cd docs && uv run mkdocs build

Confirm the new Raises: section renders on the function's docs page.

Guida contributor