Code Style¶
Ruff for linting and formatting (configured in
pyproject.toml)All functions require type annotations
Annotations name the narrowest type:
object,Anyand generics without type arguments only behind a# noqa: PANxxx - <reason>, thelcm.typingaliases (RegimeName,StateName, ...) rather than barestrfor names, andtype X = ...statements for aliases; theprecise-annotationshook checks source, tests, benchmarks and documentation notebooksGoogle-style docstrings in imperative mood (“Return”, not “Returns”)
Use
# ty: ignore[error-code]for type suppression (never# type: ignore)Never use
from __future__ import annotations
Testing¶
Plain
pytestfunctions — no test classesUse
@pytest.mark.parametrizefor test variations
Naming¶
funcfor callable abbreviations (neverfn)state_names/action_names(notstates_names)arg_names(notargument_names)
Plotting¶
Always use plotly (
plotly.graph_objects,plotly.subplots.make_subplots), never matplotlib
Docstrings¶
MyST syntax (single backticks for code,
$...$for math), not reStructuredTextInline field docstrings (PEP 257) for dataclass attributes
Docstring types must match annotations (
Mappingnot “Dict” when annotation isMapping)