diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6312378 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: +- repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black + files: '^.*\.py' + types: [file] +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + args: ['--extend-ignore=E203', '--max-line-length=88'] + files: '^.*\.py' + types: [file] +- repo: https://github.com/pycqa/isort + rev: 5.6.4 + hooks: + - id: isort + args: ['--profile', 'black'] + files: '^.*\.py' + types: [file] diff --git a/contributing/README.md b/contributing/README.md index 1d9d69d..0832187 100644 --- a/contributing/README.md +++ b/contributing/README.md @@ -18,5 +18,18 @@ $ pip install -r contributing/requirements.txt ### Run Formatter and Linter ```bash -make all +$ make all +``` + +### Enable pre-commit hook + +```bash +$ pre-commit install +``` + +Basically, `pre-commit` will only run on the changed files. +But if you execute the bellow command, you can run on all files. + +```bash +$ pre-commit run --all-files ``` diff --git a/contributing/requirements.txt b/contributing/requirements.txt index b3b14f7..e892e8f 100644 --- a/contributing/requirements.txt +++ b/contributing/requirements.txt @@ -1,3 +1,4 @@ black==20.8b1 flake8==3.8.4 -isort==5.6.4 \ No newline at end of file +isort==5.6.4 +pre-commit==2.16.0