| 1 | # Code Style |
| 2 | |
| 3 | ## Formatting |
| 4 | |
| 5 | libtmux uses [ruff](https://github.com/astral-sh/ruff) for both linting and formatting. |
| 6 | |
| 7 | ```console |
| 8 | $ uv run ruff format . |
| 9 | ``` |
| 10 | |
| 11 | ```console |
| 12 | $ uv run ruff check . --fix --show-fixes |
| 13 | ``` |
| 14 | |
| 15 | ## Type Checking |
| 16 | |
| 17 | Strict [mypy](https://mypy-lang.org/) is enforced across `src/` and `tests/`. |
| 18 | |
| 19 | ```console |
| 20 | $ uv run mypy |
| 21 | ``` |
| 22 | |
| 23 | ## Docstrings |
| 24 | |
| 25 | All public functions and methods use NumPy-style docstrings. See the |
| 26 | [NumPy docstring guide](https://numpydoc.readthedocs.io/en/latest/format.html). |
| 27 | |
| 28 | ## Imports |
| 29 | |
| 30 | - Standard library: namespace imports such as |
| 31 | [`pathlib`](https://docs.python.org/3/library/pathlib.html) (`import pathlib`, |
| 32 | not `from pathlib import Path`) |
| 33 | - Exception: [`dataclasses`](https://docs.python.org/3/library/dataclasses.html) |
| 34 | may use `from dataclasses import dataclass, field` |
| 35 | - [`typing`](https://docs.python.org/3/library/typing.html): `import typing as t`, |
| 36 | access via |
| 37 | [`t.Optional`](https://docs.python.org/3/library/typing.html#typing.Optional), |
| 38 | [`t.NamedTuple`](https://docs.python.org/3/library/typing.html#typing.NamedTuple), |
| 39 | etc. |
| 40 | - All files: `from __future__ import annotations` |