From fc6696e127aa76e56dfa7ae46b6269ca0096f5ef Mon Sep 17 00:00:00 2001
From: David Trattnig <david@subsquare.at>
Date: Mon, 1 Aug 2022 15:48:35 +0200
Subject: [PATCH] chore(pre-commit): add hooks and update conf #114

---
 .codespellignore        |  0
 .codespellrc            |  5 +++++
 .flake8                 |  5 ++---
 .pre-commit-config.yaml | 22 ++++++++++++++++++++++
 Makefile                | 20 ++++++++++++--------
 5 files changed, 41 insertions(+), 11 deletions(-)
 delete mode 100644 .codespellignore
 create mode 100644 .codespellrc
 create mode 100644 .pre-commit-config.yaml

diff --git a/.codespellignore b/.codespellignore
deleted file mode 100644
index e69de29b..00000000
diff --git a/.codespellrc b/.codespellrc
new file mode 100644
index 00000000..eaa4a6ca
--- /dev/null
+++ b/.codespellrc
@@ -0,0 +1,5 @@
+[codespell]
+exclude-file = .gitignore
+skip = ./src/aura_engine/client/playerclient.py,*.log,.git,*.png,*.db
+count =
+quiet-level = 1
\ No newline at end of file
diff --git a/.flake8 b/.flake8
index 00e2897d..9705b035 100644
--- a/.flake8
+++ b/.flake8
@@ -2,6 +2,5 @@
 max-line-length = 99
 max-doc-length = 99
 docstring-convention=google
-exclude = python, tests/*, __init__.py, src/aura_engine/client/*, meta.py
-ignore = E121,E123,E126,E203,E226,E24,E704,W503,N802,\
-    D105,D107,D200,D202
+exclude = python, tests/*, __init__.py, src/aura_engine/client/*
+ignore = E121,E123,E126,E203,E226,E24,E704,W503,N802,D105,D107,D200,D202,D212,D417
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..1c705408
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,22 @@
+repos:
+  - repo: https://github.com/psf/black
+    rev: 22.6.0
+    hooks:
+    - id: black
+  - repo: https://github.com/PyCQA/isort
+    rev: 5.10.1
+    hooks:
+      - id: isort
+  - repo: https://github.com/codespell-project/codespell
+    rev: "v2.1.0"
+    hooks:
+      - id: codespell
+        args: [""]
+  - repo: https://github.com/PyCQA/flake8
+    rev: 5.0.2
+    hooks:
+      - id: flake8
+        args: ["--config=.flake8"]
+        additional_dependencies: [
+          "flake8-docstrings"
+        ]
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 3dc8aee1..d6f92b2a 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,8 @@
 
 help::
 	@echo "$(APP_NAME) targets:"
-	@echo "    init.app        - init application environment"
+	@echo "    init.app.sys    - init application environment (sudo)"
+	@echo "    init.dev.sys    - init development environment (sudo)"
 	@echo "    init.dev        - init development environment"
 	@echo "    lint            - verify code style"
 	@echo "    spell           - check spelling of text"
@@ -62,7 +63,7 @@ DOCKER_RUN = @docker run \
 
 # Targets
 
-init.app::
+init.app.sys::
 	apt install -y \
 		python3-wheel \
 		python3-flask \
@@ -72,23 +73,26 @@ init.app::
 		python3-requests \
 		python3-sqlalchemy
 
-init.dev::
-	apt install -y
+init.dev.sys::
+	apt install -y \
 		codespell \
 		black \
+		pre-commit \
 		python3-flake8 \
 		python3-flake8-docstrings \
 		python3-validators \
 		python3-isort
 
+init.dev:: requirements.txt
+	pip install --user -Ur requirements.txt
+	pre-commit autoupdate
+	pre-commit install
+
 lint::
 	python3 -m flake8 .
 
-spell:: SPELL_PATHS := $(wildcard *.md) docs src tests config contrib
-spell:: SPELL_PATHS_SKIP := src/aura_engine/client/playerclient.py
-spell:: SPELL_IGNORE_FILE := .codespellignore
 spell::
-	codespell --ignore-words "$(SPELL_IGNORE_FILE)" --skip "$(SPELL_PATHS_SKIP)" $(SPELL_PATHS)
+	codespell
 
 style::
 	python3 -m isort .
-- 
GitLab