diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2c85f44 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: + - repo: https://github.com/PyCQA/isort + rev: 6.0.1 + hooks: + - id: isort + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 25.1.0 + hooks: + - id: black + language_version: python3 + - repo: https://github.com/PyCQA/flake8 + rev: 7.1.2 + hooks: + - id: flake8 \ No newline at end of file diff --git a/readme.md b/readme.md index 666ebe3..54d2b58 100644 --- a/readme.md +++ b/readme.md @@ -117,3 +117,17 @@ user.save() ``` 8. You can now access the /admin page. + +## Setup pre-commit + +PyLadiescon-portal uses a tool called [pre-commit](https://pre-commit.com/) to enforce coding standard and styles. To enable pre-commit, run: + +``` +pre-commit install +``` + +### Pre-commit automatically runs during the commit + +With pre-commit installed as a git hook for verifying commits, the pre-commit hooks configured in `.pre-commit-config.yaml` for PyLadiescon-portal must all pass before the commit is successful. If there are any issues found with the commit, this will cause your commit to fail. Where possible, pre-commit will make the changes needed to correct the problems it has found. + +You can then re-add any files that were modified as a result of the pre-commit checks, and re-commit the change. \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 1507b6b..6361f57 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,3 +9,4 @@ pytest-django==4.8.0 pytest==8.3.5 pytest-cov==6.1.1 coverage==7.7.0 +pre_commit==4.2.0 \ No newline at end of file