Skip to content

Commit f9bf52f

Browse files
committed
Add contributor instructions for auto-formatters
Add cli snippet to run black and isort on the command line and pointers to editor and pre-commit configuration to docs/CONTRIBUTORS.rst. Also add .pre-commit-config.yaml to .gitignore for independent pre-commit configuration. Signed-off-by: Lukas Puehringer <[email protected]>
1 parent 38ef45f commit f9bf52f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ tests/htmlcov/*
1818
.python-version
1919
*~
2020
*.tmp
21+
.pre-commit-config.yaml
2122

2223
# Debian generated files
2324
debian/.debhelper/*

docs/CONTRIBUTORS.rst

+22-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Note: Development of TUF occurs on the "develop" branch of this repository.
55

66
Contributions can be made by submitting GitHub pull requests. Submitted code
77
should follow our `code style guidelines
8-
<https://github.com/secure-systems-lab/code-style-guidelines>`_, which provide
9-
examples of what to do (or not to do) when writing Python code.
8+
<https://github.com/secure-systems-lab/code-style-guidelines>`_, which are
9+
enforced with linters and auto-formatters (details below).
1010

1111
Contributors must also indicate acceptance of the `Developer Certificate of
1212
Origin <https://developercertificate.org/>`_ (DCO) when making a contribution
@@ -105,6 +105,26 @@ To work on the TUF project, it's best to perform a development install.
105105
$ pip install -r requirements-dev.txt
106106

107107

108+
Auto-formatting
109+
===============
110+
111+
CI/CD will check that new TUF code is formatted with `black
112+
<https://black.readthedocs.io/>`__ and `isort <https://pycqa.github.io/isort>`__.
113+
Auto-formatting can be done on the command line:
114+
::
115+
116+
$ # TODO: configure black and isort args in pyproject.toml (see #1161)
117+
$ black --line-length 80 tuf/api
118+
$ isort --line-length 80 --profile black -p tuf tuf/api
119+
120+
or via source code editor plugin
121+
[`black <https://black.readthedocs.io/en/stable/editor_integration.html>`__,
122+
`isort <https://github.com/pycqa/isort/wiki/isort-Plugins>`__] or
123+
`pre-commit <https://pre-commit.com/>`__-powered git hooks
124+
[`black <https://black.readthedocs.io/en/stable/version_control_integration.html>`__,
125+
`isort <https://pycqa.github.io/isort/docs/configuration/pre-commit/>`__].
126+
127+
108128
Testing
109129
=======
110130

0 commit comments

Comments
 (0)