Skip to content

Commit 1dac756

Browse files
authored
Merge pull request #245 from LauLauThom/precommit-hooks
Add precommit hooks
2 parents 8335a81 + 797d438 commit 1dac756

File tree

19 files changed

+50
-24
lines changed

19 files changed

+50
-24
lines changed

.github/workflows/python-package.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ name: Python package
55

66
on:
77
push:
8-
branches:
8+
branches:
99
- master
10-
- dev
10+
- dev
1111
- windows
1212
pull_request:
13-
branches:
13+
branches:
1414
- master
15-
- dev
15+
- dev
1616

1717
jobs:
1818
build:

.github/workflows/python-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
ver=`python setup.py --version`
2929
tag="refs/tags/$ver"
30-
if [[ "$tag" != $GITHUB_REF ]]
30+
if [[ "$tag" != $GITHUB_REF ]]
3131
then echo Tag $GITHUB_REF does not match $ver from setup.py >&2
3232
echo Please update rocrate/_version.py
3333
false
@@ -41,5 +41,5 @@ jobs:
4141
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
4242
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
4343
run: |
44-
python setup.py sdist bdist_wheel
44+
python setup.py sdist bdist_wheel
4545
twine upload dist/*

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ENV/
101101
.mypy_cache/
102102
.pytest_cache
103103

104-
# vim
104+
# vim
105105
*.swp
106106

107107
# other

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/PyCQA/flake8
3+
rev: 7.3.0
4+
hooks:
5+
- id: flake8
6+
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v6.0.0 # Use the ref you want to point at
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-merge-conflict
13+
- id: check-json
14+
- id: check-yaml
15+
- id: debug-statements

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ author:
4949
- family-names: Thomas
5050
given-names: Laurent
5151
orcid: https://orcid.org/0000-0001-7686-3249
52-
52+
5353
title: "ro-crate-py"
5454
version: 0.14.2
5555
doi: 10.5281/zenodo.3956493

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ pip install flake8
8585
flake8 --exclude venv ./
8686
```
8787

88+
### Pre-commit hooks
89+
ro-crate-py comes with a configuration file for [pre-commit](https://github.com/pre-commit/pre-commit) `.pre-commit-config.yaml`.
90+
This configuration file defines so-called "hooks" which are executed upon each commit, to automatically format the code in the commited files according to the requirements defined for instance in the flake8 configuration file (e.g removing spaces from blank lines...).
91+
92+
To benefit from these automated hooks, you need first to install the pre-commit package.
93+
`pip install pre-commit`
94+
95+
The hooks should then be installed once for your local copy of the repository by running the following command in the root of the repo.
96+
`pre-commit install`
97+
98+
Once installed the hooks will be executed each time a new commit is made, for the files being commited.
99+
If some checks failed or could not be fixed automatically, an error message will be shown and the commit will be aborted.
100+
101+
While not recommended, you can bypass the hooks by passing the additional flag `--no-verify` to the `git commit` command.
102+
103+
Some IDEs have plugins for precommit (e.g [here](https://marketplace.visualstudio.com/items?itemName=elagil.pre-commit-helper) for VSCode), which would for instance run the hooks for the currently opened file each time it is saved. The plugins typically pick up the configuration file automatically.
104+
88105
### Testing
89106

90107
Testing is done with [pytest](https://pytest.org):

notebooks/ExploreSchemaOrg.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,4 +1170,3 @@
11701170
"nbformat": 4,
11711171
"nbformat_minor": 2
11721172
}
1173-

notebooks/ROcrate-linked-data.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2775,4 +2775,3 @@
27752775
"nbformat": 4,
27762776
"nbformat_minor": 2
27772777
}
2778-

notebooks/ROcrate-validation.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,4 +579,3 @@
579579
"nbformat": 4,
580580
"nbformat_minor": 2
581581
}
582-

notebooks/sample_data/clinvap/ro-crate-metadata.jsonld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@
150150
}
151151
}
152152
]
153-
}
153+
}

0 commit comments

Comments
 (0)