Skip to content

Commit

Permalink
Add contributor instructions for auto-formatters
Browse files Browse the repository at this point in the history
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 <lukas.puehringer@nyu.edu>
  • Loading branch information
lukpueh committed Mar 17, 2021
1 parent 38ef45f commit 2e883d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tests/htmlcov/*
.python-version
*~
*.tmp
.pre-commit-config.yaml

# Debian generated files
debian/.debhelper/*
Expand Down
24 changes: 22 additions & 2 deletions docs/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Note: Development of TUF occurs on the "develop" branch of this repository.

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

Contributors must also indicate acceptance of the `Developer Certificate of
Origin <https://developercertificate.org/>`_ (DCO) when making a contribution
Expand Down Expand Up @@ -104,6 +104,26 @@ To work on the TUF project, it's best to perform a development install.

$ pip install -r requirements-dev.txt

Auto-formatting
===============

CI/CD will check that new TUF code is formatted with `black
<https://black.readthedocs.io/>`__ and `isort <https://pycqa.github.io/isort>`__.
Auto-formatting can be done on the command line:
::

$ # TODO: configure black and isort args in pyproject.toml (see #1161)
$ black --line-length 80 tuf/api
$ isort --line-length 80 --profile black -p tuf tuf/api

or via source code editor plugin
[`black <https://black.readthedocs.io/en/stable/editor_integration.html>`__,
`isort <https://github.com/pycqa/isort/wiki/isort-Plugins>`__] or
`pre-commit <https://pre-commit.com/>`__-powerd git hooks
[`black <https://black.readthedocs.io/en/stable/version_control_integration.html>`__,
`isort <https://pycqa.github.io/isort/docs/configuration/pre-commit/>`__].



Testing
=======
Expand Down

0 comments on commit 2e883d4

Please sign in to comment.