Skip to content

Commit a7d0003

Browse files
committed
Add pre-commit hooks
1 parent 4c72f9a commit a7d0003

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/ambv/black
5+
rev: stable
6+
hooks:
7+
- id: black
8+
language_version: python3.8
9+
- repo: https://gitlab.com/pycqa/flake8
10+
rev: 3.8.3
11+
hooks:
12+
- id: flake8

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ setup: #: Use pip-tools, pip-compile, pip install
6060
pip install -r requirements/requirements.txt
6161
@echo "$(BOLD_CYAN)Installing dev requirements$(RESET_STYLES)"
6262
pip install -r requirements/dev-requirements.txt
63+
@echo "$(BOLD_CYAN)Adding pre-commit hooks$(RESET_STYLES)"
64+
pre-commit install
6365

6466

6567
format: #: Format and fix python code with black, isort, autoflake
@@ -83,4 +85,7 @@ lint: #: Run static analysis with flake8, mypy and bandit
8385
@echo "$(BOLD_CYAN)Securing with bandit️🕵️️$(RESET_STYLES)"
8486
bandit --version
8587
bandit -l -i -r . --format=custom
88+
@echo "$(BOLD_CYAN)Running pre-commit hooks 🏁️️️$(RESET_STYLES)"
89+
pre-commit run --all-files
90+
@echo "$(BOLD_CYAN)All checks passed 🏳️️️️$(RESET_STYLES)"
8691

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Tools
1414
[![Static Analysis: flake8](https://img.shields.io/badge/static%20analysis-flake8-white.svg)](https://www.python.org/dev/peps/pep-0008/)
1515
[![Static Typing: mypy](https://img.shields.io/badge/static%20typing-mypy-blue.svg)](https://www.python.org/dev/peps/pep-0008/)
1616
[![Security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
17+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
1718

1819
Development Status
1920
------------------------------------------------------------------------------

requirements/dev-requirements.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ flake8-pytest
2424
flake8-pytest-style
2525
flake8-return
2626
pep8-naming
27+
28+
# A framework for managing and maintaining multi-language pre-commit hooks
29+
pre-commit

requirements/dev-requirements.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
#
55
# pip-compile --output-file=requirements/dev-requirements.txt requirements/dev-requirements.in
66
#
7-
appdirs==1.4.4 # via black
7+
appdirs==1.4.4 # via black, virtualenv
88
astroid==2.4.2 # via pylint
99
attrs==19.3.0 # via black
1010
autoflake==1.3.1 # via -r requirements/dev-requirements.in
1111
bandit==1.6.2 # via -r requirements/dev-requirements.in
1212
black==19.10b0 # via -r requirements/dev-requirements.in
13+
cfgv==3.2.0 # via pre-commit
1314
click==7.1.2 # via black
15+
distlib==0.3.1 # via virtualenv
16+
filelock==3.0.12 # via virtualenv
1417
flake8-blind-except==0.1.1 # via -r requirements/dev-requirements.in
1518
flake8-breakpoint==1.1.0 # via -r requirements/dev-requirements.in
1619
flake8-builtins==1.5.3 # via -r requirements/dev-requirements.in
@@ -26,26 +29,30 @@ flake8-return==1.1.2 # via -r requirements/dev-requirements.in
2629
flake8==3.8.3 # via -r requirements/dev-requirements.in, flake8-builtins, flake8-comprehensions, flake8-flask, flake8-polyfill, flake8-print, flake8-pytest
2730
gitdb==4.0.5 # via gitpython
2831
gitpython==3.1.7 # via bandit
32+
identify==1.4.25 # via pre-commit
2933
isort==4.3.21 # via -r requirements/dev-requirements.in, pylint
3034
lazy-object-proxy==1.4.3 # via astroid
3135
mccabe==0.6.1 # via flake8, pylint
3236
mypy-extensions==0.4.3 # via mypy
3337
mypy==0.782 # via -r requirements/dev-requirements.in
38+
nodeenv==1.4.0 # via pre-commit
3439
pathspec==0.8.0 # via black
3540
pbr==5.4.5 # via stevedore
3641
pep8-naming==0.11.1 # via -r requirements/dev-requirements.in
42+
pre-commit==2.6.0 # via -r requirements/dev-requirements.in
3743
pycodestyle==2.6.0 # via flake8, flake8-print
3844
pyflakes==2.2.0 # via autoflake, flake8
3945
pylint==2.5.3 # via -r requirements/dev-requirements.in
40-
pyyaml==5.3.1 # via bandit
46+
pyyaml==5.3.1 # via bandit, pre-commit
4147
r2c-py-ast==0.1.0b1 # via flake8-flask
4248
regex==2020.7.14 # via black
43-
six==1.15.0 # via astroid, bandit, flake8-print
49+
six==1.15.0 # via astroid, bandit, flake8-print, virtualenv
4450
smmap==3.0.4 # via gitdb
4551
stevedore==3.2.0 # via bandit
46-
toml==0.10.1 # via black, pylint
52+
toml==0.10.1 # via black, pre-commit, pylint
4753
typed-ast==1.4.1 # via black, mypy
4854
typing-extensions==3.7.4.2 # via mypy
55+
virtualenv==20.0.30 # via pre-commit
4956
wrapt==1.12.1 # via astroid
5057

5158
# The following packages are considered to be unsafe in a requirements file:

0 commit comments

Comments
 (0)