diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b47fa80 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +# Black version is kept in sync with .github/workflows/code_style.yml +repos: + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.1.0 + hooks: + - id: black + args: ["--line-length=120"] diff --git a/README.md b/README.md index 7032d5a..09daa23 100644 --- a/README.md +++ b/README.md @@ -192,3 +192,15 @@ For running test do: pip install pytest pytest-cov coveralls pytest --cov-report html --cov=mergin mergin/test/ ``` + +### Code style + +Code is formatted with [black](https://github.com/psf/black) (line length 120), enforced in CI. +To run the same check automatically before each commit, install the [pre-commit](https://pre-commit.com/) hooks once: + +```bash + pip install pre-commit + pre-commit install +``` + +The hook then runs on every `git commit`.