I want to lint check at the time of git commit so that I can not commit if the check does not pass. I didn't want to do automatic formatting this time, so I just did a lint check. By the way, if you want to lint check + automatic format, this area → Execute formatter at pre-commit
Install pre-commit + flake8
cd $GIT_PROJECT
pipenv install pre-commit
pipenv install flake8
Create a config file for pre-commit .pre-commit-config.yaml
repos:
- repo: https://gitlab.com/PyCQA/flake8
rev: master
hooks:
- id: flake8
Create a config file for .flake8 .flake8
[flake8]
ignore = E501 #Set the number of characters check per line to ignore
; exclude = tests/*
max-complexity = 10
Generate a script for .git/hook/pre-commit
pre-commit install
This completes the pre-commit settings. At this point, you can put in a mechanism that each developer can format.
For example, in the case of VS Code, the following article will be helpful ↓ Introduce flake8 instead of pylint in VS Code Python development environment and set automatic formatting