From 98785ddbaf0fcd973cd0fc1a96738a36f883be18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gerhard=20Br=C3=A4unlich?= <g.braeunlich@disroot.org>
Date: Fri, 12 Aug 2022 17:00:32 +0200
Subject: [PATCH] Include black in CI

---
 .gitlab-ci.yml                            |  1 +
 {{cookiecutter.repo_name}}/.gitlab-ci.yml |  3 +--
 {{cookiecutter.repo_name}}/pyproject.toml | 29 +++++++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cf9cb75..7bff27f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,4 +8,5 @@ tests:
         - cd pythonproject
         - pip install -e .[dev]
         - tox
+        - tox -e style format
         - tox -e docs
diff --git a/{{cookiecutter.repo_name}}/.gitlab-ci.yml b/{{cookiecutter.repo_name}}/.gitlab-ci.yml
index 448c168..ea45443 100644
--- a/{{cookiecutter.repo_name}}/.gitlab-ci.yml
+++ b/{{cookiecutter.repo_name}}/.gitlab-ci.yml
@@ -9,11 +9,10 @@ style:
         - python
     script:
         - pyenv local $(latest_python 3.7)
-        - tox -e style -i https://cosmo-pypi.phys.ethz.ch/simple
+        - tox -e style format -i https://cosmo-pypi.phys.ethz.ch/simple
     allow_failure: true
     stage: style
 
-
 tests:
     tags:
         - python
diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml
index 7705a1e..1bfe861 100644
--- a/{{cookiecutter.repo_name}}/pyproject.toml
+++ b/{{cookiecutter.repo_name}}/pyproject.toml
@@ -3,6 +3,22 @@ requires = ["setuptools >= 40.6.0", "wheel"]
 build-backend = "setuptools.build_meta"
 
 
+[tool.black]
+include = '\.pyi?$'
+exclude = '''
+(
+    \.eggs
+  | \.git
+  | \.mypy_cache
+  | \.tox
+  | \.venv
+  | venv
+  | _build/
+  | build/
+  | dist
+)
+'''
+
 [tool.pytest.ini_options]
 addopts = "-v -ra"
 testpaths = ["tests"]
@@ -21,6 +37,7 @@ envdir =
     py310: {toxworkdir}/py310
     docs: {toxworkdir}/py39
     style: {toxworkdir}/py39
+    format: {toxworkdir}/py39
 
 [testenv]
 setenv =
@@ -47,6 +64,18 @@ commands =
     flake8 --max-line-length=100 tests src/{{ cookiecutter.repo_name }}
 
 
+[testenv:format]
+deps =
+    black
+basepython =
+    python3.9
+skipsdist = True
+skip_install = True
+
+commands =
+    black --check .
+
+
 [testenv:docs]
 basepython =
     python3.9
-- 
GitLab