diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 797fb4b0..77e4a0c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,5 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks repos: - repo: local hooks: @@ -6,3 +8,10 @@ repos: entry: python ./commons/git_hooks/enforce_semantic_commit_msg.py language: python stages : [commit-msg] +- repo: https://github.com/psf/black + rev: stable + hooks: + - id: black + args: [--line-length=79, --skip-string-normalization] + name: Check formatted code + stages: [commit] \ No newline at end of file diff --git a/README.md b/README.md index 01861dea..7f905643 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Remember to do it with Python 3. Bear in mind that the requirements for `time_tracker_events`, must be located on its local requirements.txt, by [convention](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#folder-structure). -- Run `pre-commit install`. For more details, check out Development > Git hooks. +- Run `pre-commit install -t pre-commit -t commit-msg`. For more details, see section Development > Git hooks. ### How to use it - Set the env var `FLASK_APP` to `time_tracker_api` and start the app: @@ -153,11 +153,10 @@ func azure functionapp publish time-tracker-events --build local We use [pre-commit](https://github.com/pre-commit/pre-commit) library to manage local git hooks, as developers we just need to run in our virtual environment: ``` -pre-commit install +pre-commit install -t pre-commit -t commit-msg ``` With this command the library will take configuration from `.pre-commit-config.yaml` and will set up the hooks by us. -Currently, we only have a hook to enforce semantic commit message. ### Test We are using [Pytest](https://docs.pytest.org/en/latest/index.html) for tests. The tests are located in the package