|
2 | 2 |
|
3 | 3 | ## Development |
4 | 4 |
|
5 | | -- Use a virtual environment and pip for building and packaging of this Python project. For local development, create and activate a venv, then install the extras with pip. |
| 5 | +### Environment setup |
6 | 6 |
|
7 | | -- We're using `pytest` for testing the code and a variety of plugins for linting |
8 | | - and checking for bugs, including: |
| 7 | +Development uses [devbox](https://www.jetify.com/devbox) to provide a |
| 8 | +reproducible, isolated shell with all required tools (Python 3.12, `uv`, |
| 9 | +`just`, `taskwarrior`, etc.) without touching your system packages. |
9 | 10 |
|
10 | | - - [mypy](http://mypy-lang.org/) |
11 | | - - [pyright](https://github.com/Microsoft/pyright) |
12 | | - - [pycln](https://hadialqattan.github.io/pycln/) |
13 | | - - [isort](https://pypi.org/project/isort/) |
14 | | - - [pre-commit](https://pre-commit.com/) |
| 11 | +1. [Install devbox](https://www.jetify.com/docs/devbox/installing-devbox). |
15 | 12 |
|
16 | | - All these development dependencies will be available inside a virtual |
17 | | - environment. Recommended steps: |
| 13 | +1. Enter the dev shell and set up the project in one go: |
18 | 14 |
|
19 | | - ```sh |
20 | | - # create and activate a venv (example) |
21 | | - python -m venv .venv |
22 | | - source .venv/bin/activate |
23 | | - python -m pip install --upgrade pip |
| 15 | + ```sh |
| 16 | + devbox shell |
| 17 | + just setup-dev |
| 18 | + ``` |
24 | 19 |
|
25 | | - # install development and optional extras for testing |
26 | | - python -m pip install -e ".[all]" |
27 | | - ``` |
| 20 | + `devbox shell` activates the environment (creates a `.venv` and installs |
| 21 | + Python dependencies via `uv` automatically on first run). `just setup-dev` |
| 22 | + installs the package in editable mode and registers the `pre-commit` hooks. |
28 | 23 |
|
29 | | - To run all the linters in one go you can use `pre-commit`. To do this: |
| 24 | +1. For subsequent sessions just re-enter the shell: |
30 | 25 |
|
31 | | - 1. Setup the `virtualenv` as described above. |
32 | | - 1. Get a shell inside the virtualenv. Install the `pre-commit` hook. |
| 26 | + ```sh |
| 27 | + devbox shell # or: just shell |
| 28 | + ``` |
33 | 29 |
|
34 | | - ```sh |
35 | | - pre-commit install |
36 | | - ``` |
| 30 | +### Common tasks via `just` |
37 | 31 |
|
38 | | - 1. While inside this `virtualenv` you can run `pre-commit run --all-files` to |
39 | | - run all the linting/formatting checks (excluding the tests). |
40 | | - 1. The linting and formatting programs will run on all files that changed on |
41 | | - every new commit automatically. |
| 32 | +`just` is the project's task runner. Run `just` (no arguments) inside the dev |
| 33 | +shell to list all available recipes. |
42 | 34 |
|
43 | | -- To run the tests just run `pytest`. The pytest configuration for this project |
44 | | - (as well as the configuration for each one of the tools can be found in the |
45 | | - `pyproject.toml` file. At the time of writing it's the following: |
| 35 | +| Recipe | What it does | |
| 36 | +|---|---| |
| 37 | +| `just setup-dev` | Full first-time setup (deps + pre-commit) | |
| 38 | +| `just setup-deps` | Re-install Python dependencies only | |
| 39 | +| `just setup-pre-commit` | (Re-)install pre-commit hooks | |
| 40 | +| `just shell` | Open a devbox shell | |
| 41 | +| `just check` | Run all pre-commit checks across the whole codebase | |
| 42 | +| `just test` | Run the test suite | |
| 43 | +| `just gen-completions` | Regenerate shell completions | |
46 | 44 |
|
47 | | - ```toml |
48 | | - # pytest ----------------------------------------------------------------------- |
49 | | - [tool.pytest.ini_options] |
50 | | - addopts = ["--ignore-glob=quickstart*", "--doctest-modules"] |
51 | | - ``` |
| 45 | +### Linting and formatting |
| 46 | + |
| 47 | +The project uses [ruff](https://docs.astral.sh/ruff/) for linting and |
| 48 | +formatting, wired up through [pre-commit](https://pre-commit.com/). The |
| 49 | +configuration lives in `pyproject.toml` under `[tool.ruff]`. |
| 50 | + |
| 51 | +Use `just check` to run all checks (including ruff) across the whole codebase: |
| 52 | + |
| 53 | +```sh |
| 54 | +just check |
| 55 | +``` |
| 56 | + |
| 57 | +All hooks also run automatically on every commit. To run only the ruff hooks: |
| 58 | + |
| 59 | +```sh |
| 60 | +pre-commit run ruff --all-files |
| 61 | +``` |
| 62 | + |
| 63 | +### Running the tests |
| 64 | + |
| 65 | +```sh |
| 66 | +just test |
| 67 | +``` |
| 68 | + |
| 69 | +The pytest configuration lives in `pyproject.toml`. |
| 70 | + |
| 71 | +### Isolating test runs from your real data |
52 | 72 |
|
53 | | -- If you want to test your changes during development but don't want to tamper |
54 | | - with your existing synchronizations, consider setting the `SYNCALL_TESTENV` |
55 | | - environment variable before execution. With this variable set, `syncall` |
56 | | - instead of `$XDG_CONFIG_HOME/syncall,` will use the |
57 | | - `$XDG_CONFIG_HOME/test_syncall` directory. |
| 73 | +Set `SYNCALL_TESTENV` before running a sync executable to redirect all config |
| 74 | +reads/writes to `$XDG_CONFIG_HOME/test_syncall` instead of the default |
| 75 | +`$XDG_CONFIG_HOME/syncall`. This lets you experiment without touching your |
| 76 | +live synchronization data. |
58 | 77 |
|
59 | 78 | ## Git Guidelines |
60 | 79 |
|
|
0 commit comments