Skip to content

Commit

Permalink
Add a pre-commit config file
Browse files Browse the repository at this point in the history
and document it briefly in the README file.

This comes with a few checkers:
- flake8
- trailing-whitespace
- check-json
- check-yaml
- codespell

Also include commented checkers:
- black: disabled since we are not ready for this yet,
- pydocstyle: disabled since we have way too many pydoctyle errors for now...

See https://pre-commit.com/ for more details.

Related to T1881.
  • Loading branch information
douardda committed Jul 10, 2019
1 parent 9812fe7 commit 0f4c2e4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
- id: trailing-whitespace
- id: flake8
- id: check-json
- id: check-yaml

- repo: https://github.com/codespell-project/codespell
rev: v1.15.0
hooks:
- id: codespell

# unfortunately, we are far from being able to enable this...
# - repo: https://github.com/PyCQA/pydocstyle.git
# rev: 4.0.0
# hooks:
# - id: pydocstyle
# name: pydocstyle
# description: pydocstyle is a static analysis tool for checking compliance with Python docstring conventions.
# entry: pydocstyle --convention=google
# language: python
# types: [python]

# black requires py3.6+
#- repo: https://github.com/python/black
# rev: 19.3b0
# hooks:
# - id: black
# language_version: python3
#- repo: https://github.com/asottile/blacken-docs
# rev: v1.0.0-1
# hooks:
# - id: blacken-docs
# additional_dependencies: [black==19.3b0]
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To set up your development environment:

This will install every Python package needed to run this package's tests.

Unit tests can be executed using [pytest](https://docs.pytest.org).
Unit tests can be executed using [pytest][2] or [tox][3].

```
(swh) user@host:~/swh-environment/swh-core$ pytest
Expand All @@ -46,8 +46,21 @@ swh/core/tests/test_utils.py ....... [100%]
===================== 89 passed, 9 warnings in 6.94 seconds =====================
```

Note: this git repository uses [pre-commit][4] hooks to ensure better and more
consistent code. It should already be installed in your virtualenv (if not,
just type `pip install pre-commit`). Make sure to activate it in your local
copy of the git repository:

```
(swh) user@host:~/swh-environment/swh-core$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
```

Please read the [developer setup manual][5] for more information on how to hack
on Software Heritage.

[2]: https://docs.softwareheritage.org/devel/developer-setup.html
[1]: https://virtualenv.pypa.io
[2]: https://docs.pytest.org
[3]: https://tox.readthedocs.io
[4]: https://pre-commit.com
[5]: https://docs.softwareheritage.org/devel/developer-setup.html
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pytest < 4
pytest-postgresql
requests-mock
hypothesis >= 3.11.0
pre-commit

0 comments on commit 0f4c2e4

Please sign in to comment.