Add black to pre-commit 44/15144/3
authorThanh Ha <zxiiro@gmail.com>
Sun, 31 Mar 2019 00:48:54 +0000 (20:48 -0400)
committerThanh Ha <zxiiro@gmail.com>
Fri, 24 Jul 2020 13:27:44 +0000 (09:27 -0400)
* Requires Python 3.6 or newer
* Changes pep8 max line length to 88 to match black
* Add .editorconfig to match black config
* Update tox to 2.0 to match black recommended version

This patch uses "black" to automatically manage Python style
conventions so that we don't have to. It utilizes pre-commit
to automatically handle running black on commit so that a
contributor does not have to think about it.

This however means that there is a required install step to
initialize a new dev environment using one of 2 options below:

1) Install pre-commit via your pkg manager then run:

    pre-commit install

2) Use tox to install pre-commit:

    tox -e check-hooks

Change-Id: I527e58b763dc7b0fdfa60fa619c61d2c63356d47
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
.coafile
.editorconfig [new file with mode: 0644]
.pre-commit-config.yaml
tox.ini

index edba4bd..9f05225 100644 (file)
--- a/.coafile
+++ b/.coafile
@@ -21,7 +21,7 @@ files = docs_conf/**.py
 known_first_party_imports = lftools
 known_third_party_imports = pytest, six, sphinx_bootstrap_theme
 pydocstyle_ignore = D203, D213, D301
-max_line_length = 120
+max_line_length = 88
 
 [all.YAML]
 bears = YAMLLintBear
diff --git a/.editorconfig b/.editorconfig
new file mode 100644 (file)
index 0000000..f77fecb
--- /dev/null
@@ -0,0 +1,18 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = space
+
+[*.rst]
+indent_size = 4
+
+[*.py]
+indent_size = 4
+max_line_legth = 88
+
+[*.yaml]
+indent_size = 4
+
index ed75449..9a6ec31 100644 (file)
@@ -10,3 +10,8 @@ repos:
     hooks:
     -   id: gitlint
 
+  - repo: https://github.com/ambv/black
+    rev: stable
+    hooks:
+    - id: black
+      language_version: python3
diff --git a/tox.ini b/tox.ini
index 6c855dc..affd716 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-minversion = 1.9
+minversion = 2.0
 envlist =
     coala,
     docs,