1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
Contributing to Kalamine
================================================================================
Setup
--------------------------------------------------------------------------------
After checking out the repository, you can install kalamine and its development dependencies like this:
```bash
python3 -m pip install --user .[dev]
```
Which is the equivalent of:
```bash
python3 -m pip install --user -e .
python3 -m pip install --user build black isort ruff pytest mypy types-PyYAML pre-commit
```
There’s also a Makefile recipe for that:
```bash
make dev
```
Code Formating
--------------------------------------------------------------------------------
We rely on [black][1] and [isort][2] for that, with their default configurations:
```bash
black kalamine
isort kalamine
```
Alternative:
```bash
make format
```
[1]: https://black.readthedocs.io
[2]: https://pycqa.github.io/isort/
Code Linting
--------------------------------------------------------------------------------
We rely on [ruff][3] and [mypy][4] for that, with their default configurations:
```bash
black --check --quiet kalamine
isort --check --quiet kalamine
ruff check kalamine
mypy kalamine
```
Alternative:
```bash
make lint
```
Many linting errors can be fixed automatically:
```bash
ruff check --fix kalamine
```
[3]: https://docs.astral.sh/ruff/
[4]: https://mypy.readthedocs.io
Unit Tests
--------------------------------------------------------------------------------
We rely on [pytest][5] for that, but the sample layouts must be built by
kalamine first:
```bash
python3 -m kalamine.cli make layouts/*.toml
pytest
```
Alternative:
```bash
make test
```
[5]: https://docs.pytest.org
Before Committing
--------------------------------------------------------------------------------
You may ensure manually that your commit will pass the Github CI (continuous integration) with:
```bash
make
```
But setting up a git pre-commit hook is strongly recommended. Just create an executable `.git/hooks/pre-commit` file containing:
```bash
#!/bin/sh
make
```
This is asking git to run the above command before any commit is created, and to abort the commit if it fails.
|