Commit 1d28d7fd authored by Joao P C Bertoldo's avatar Joao P C Bertoldo
Browse files

Merge branch '5-git-commit-hooks'

parents c68092ae 5b9c530d
minimum_pre_commit_version: 2.12.0
default_language_version:
python: python3.8
files: 'zUtil_Python/.+'
exclude: |
(?x)^(
.+\.m|
.+\.cpp|
.+\.css|
.+\.cxx|
.+\.txx|
.+\.h|
.+\.tex|
.+\.cc|
.+\.txt|
.+\.bib|
.+\.html|
.+\.xml|
.+\.pl
)$
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 20.8b1 # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black
language_version: python3.8 # Should be a command that runs python3.6+
- repo: https://github.com/pycqa/flake8
rev: '3.9.0' # pick a git hash / tag to point to
hooks:
- id: flake8
\ No newline at end of file
......@@ -110,3 +110,45 @@ $ python /users/user1/dct/dct_launch.py
9. For more information or support, contact graintracking@esrf.fr
# dev
## pre-commit hooks
[pre-commit's official website](https://pre-commit.com/)
first, let's create an isolated environment for pre-commit
```
# using a conda installation that I found at `cat $(which silx)`
os=$(/csadmin/common/scripts/get_os)
source /sware/isdd/packages/${os}/dau/miniconda3/etc/profile.d/conda.sh
# create an empty installation of python 3.8
# src: https://stackoverflow.com/a/37216638/9582881
conda create --yes --prefix $HOME/.pre-commit-env -c conda-forge python=3.8 pre-commit
```
Make the pre-commit executable accessible locally:
```
# link the executable to your local path
ln -s ~/.pre-commit-env/bin/pre-commit ~/.local/bin/
```
Now check that you have pre-commit properly installed:
```
which pre-commit
# should be like /nana/ni/nana/na/.local/bin/pre-commit
pre-commit -V
# should be >= 2.12.0
```
Finally, let's activate it for the project:
```
cd ~/dct # or wherever you put it...
pre-commit install
```
[tool.black]
line-length = 127
target-version = ['py36', 'py37', 'py38']
include = '\.pyi?$'
\ No newline at end of file
[flake8]
max-line-length = 127
max-complexity = 10
ignore = E203, E266, E501, W503, F403, F401
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment