]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Enforce Python codestyle with black
authorTom Krizek <tkrizek@isc.org>
Tue, 7 Jun 2022 14:06:05 +0000 (16:06 +0200)
committerTom Krizek <tkrizek@isc.org>
Wed, 8 Jun 2022 08:27:46 +0000 (10:27 +0200)
Black is an opinionated tool for auto-formatting Python code so we no
longer have to worry about the codestyle.

For the codestyle decisions and discussion, refer to the upstream
documentation [1].

[1] https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html

.gitlab-ci.yml
doc/dev/style.md

index 466c3d1d41a2b4d647ef61094681b9c11cb4d8e8..a8c54d47e176e28095073d2cbff349f5a1b978c1 100644 (file)
@@ -427,6 +427,19 @@ misc:
     expire_in: "1 day"
     when: on_failure
 
+black:
+  <<: *precheck_job
+  needs: []
+  script:
+    - black $(git ls-files '*.py')
+    - git diff > black.patch
+    - if test "$(git status --porcelain | grep -Ev '\?\?' | wc -l)" -gt "0"; then git status --short; exit 1; fi
+  artifacts:
+    paths:
+      - black.patch
+    expire_in: "1 week"
+    when: on_failure
+
 clang-format:
   <<: *precheck_job
   needs: []
index 3cc0a0aec5e4fa53220562f26dc386b652add1d9..f4b79c5af561982d035f920182581e7a16dcf13a 100644 (file)
@@ -855,9 +855,9 @@ name server. However, BIND 9 may use it for its system test
 environment, and in some cases for generating source or documentation
 files which are then committed to to the git repository.
 
-For Python coding, we abide by the Python style guidelines described
-in [PEP8](http://www.python.org/dev/peps/pep-0008/), with a few
-modifications:
+For Python coding, we enforce a common codestyle using the tool
+[black](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html)
+There are also a few other requirements:
 
 * The `__init__()` method should always be the first one declared in a
   class definition, like so: