From 07a5b3249e5a38ce0d8c1b49fe72e24cb246a0a5 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Sat, 30 Mar 2019 20:48:54 -0400 Subject: [PATCH] Add black to pre-commit * 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 --- .coafile | 2 +- .editorconfig | 18 ++++++++++++++++++ .pre-commit-config.yaml | 5 +++++ tox.ini | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .editorconfig diff --git a/.coafile b/.coafile index edba4bd..9f05225 100644 --- 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 index 0000000..f77fecb --- /dev/null +++ b/.editorconfig @@ -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 + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ed75449..9a6ec31 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -minversion = 1.9 +minversion = 2.0 envlist = coala, docs, -- 2.16.6