configuring black

This commit is contained in:
lucasmbrown-usds 2022-09-27 20:16:36 -04:00
commit 45d05be034
2 changed files with 61 additions and 11 deletions

View file

@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: requirements-txt-fixer
- repo: https://github.com/lucasmbrown/mirrors-autoflake
rev: v1.3
hooks:
- id: autoflake
args:
[
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variable",
"--ignore-init-module-imports",
]
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.8.3
hooks:
- id: reorder-python-imports
language_version: python3.9
args:
[
"--application-directories=.",
]
- repo: https://github.com/ambv/black
rev: 22.8.0
hooks:
- id: black
language_version: python3.9

View file

@ -252,6 +252,21 @@ Each run can take a while to build the whole environment. If you'd like to save
you can use the previously built environment by running `poetry run tox -e lint` you can use the previously built environment by running `poetry run tox -e lint`
which will drastically speed up the process. which will drastically speed up the process.
### Configuring pre-commit hooks
To promote consistent code style and quality, we use git pre-commit hooks to automatically lint and reformat our
code before every commit we make to the codebase. Pre-commit hooks are defined in
[`.pre-commit-config.yaml`](../.pre-commit-config.yaml).
1. First, install [`pre-commit`](https://pre-commit.com/) globally:
$ brew install pre-commit
2. Run `pre-commit install` to install the specific git hooks used in this repository.
Now, any time you commit code to the repository, the hooks will run on all modified files automatically. If you wish,
you can force a re-run on all files with `pre-commit run --all-files`.
### The Application entrypoint ### The Application entrypoint
After installing the poetry dependencies, you can see a list of commands with the following steps: After installing the poetry dependencies, you can see a list of commands with the following steps: