Skip to content

Commit

Permalink
Add basic pre-commit configuration for tuf/api/*
Browse files Browse the repository at this point in the history
Add optional pre-commit configuration to install and run
auto-formatters when committing new code to tuf/api/*.
Auto-formatters include:
- trailing-whitespace
- end-of-file-fixer
- black
- isort

This commit also adds pre-commit to the dev dependencies
and updates the contributor instructions accordingly.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
  • Loading branch information
lukpueh committed Mar 12, 2021
1 parent 5a626ca commit 44aea45
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
files: ^tuf/api/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
# TODO: configure args in pyproject.toml (see #1161)
args: [--line-length=80, tuf/api]

- repo: https://github.com/pycqa/isort
rev: 5.7.0
hooks:
- id: isort
# TODO: configure args in pyproject.toml (see #1161)
args: [--line-length=80, --profile=black, tuf/api]
10 changes: 10 additions & 0 deletions docs/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ To work on the TUF project, it's best to perform a development install.
$ pip install -r requirements-dev.txt


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

New TUF code should be auto-formatted with `black <https://black.readthedocs.io/>`_
and `isort <https://pycqa.github.io/isort>`_. The tasks can be installed as
`pre-commit <https://pre-commit.com/>`_ git hooks with the following command.
::
$ pre-commit install


Testing
=======

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Install tuf in editable mode and requirements for local testing with tox,
# and also for running test suite or individual tests manually
tox
pre-commit
-r requirements-test.txt
-e .

0 comments on commit 44aea45

Please sign in to comment.