Enforce Python codestyle with black
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
This commit is contained in:
@@ -428,6 +428,19 @@ misc:
|
||||
expire_in: "1 day"
|
||||
when: on_failure
|
||||
|
||||
black:
|
||||
<<: *precheck_job
|
||||
needs: []
|
||||
script:
|
||||
- black $(git ls-files '*.py' '*.py.in')
|
||||
- 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: []
|
||||
|
||||
@@ -852,7 +852,9 @@ program's inputs or operation.
|
||||
|
||||
BIND 9 contains some optional tools written in Python, in the `bin/python` subdirectory. Python scripts are stored in the git repository as `{toolname}.py.in`; and `{toolname}.py` will be generated by `configure` (which determines, among other things, the path to the Python interpreter).
|
||||
|
||||
For Python coding, we abide by the Python style guidelines described [here](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:
|
||||
|
||||
Reference in New Issue
Block a user