Skip to content

Commit 6342964

Browse files
jaron-leeadam2392
andauthored
[ENH] Add pre-commit hooks (#68)
* add pre-commit hook Signed-off-by: Jaron Lee <[email protected]> * update pr number Signed-off-by: Jaron Lee <[email protected]> * update contributing with pre commit hook info Signed-off-by: Jaron Lee <[email protected]> --------- Signed-off-by: Jaron Lee <[email protected]> Co-authored-by: Adam Li <[email protected]>
1 parent c1b4107 commit 6342964

File tree

5 files changed

+646
-236
lines changed

5 files changed

+646
-236
lines changed

.pre-commit-config.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Install pre-commit hooks via
2+
# pre-commit install
3+
4+
repos:
5+
- repo: https://github.com/floatingpurr/sync_with_poetry
6+
rev: "0.4.0" # the revision or tag to clone at
7+
hooks:
8+
- id: sync_with_poetry
9+
args: ["--all"] # optional args
10+
- repo: https://github.com/psf/black
11+
rev: 22.12.0
12+
hooks:
13+
- id: black
14+
- repo: https://github.com/pycqa/isort
15+
rev: 5.12.0
16+
hooks:
17+
- id: isort
18+
name: isort (python)
19+
args: ["--profile", "black", "--filter-files", "--skip", "__init__.py"]
20+
files: ^dodiscover/
21+
- repo: https://github.com/PyCQA/bandit
22+
rev: 1.7.4
23+
hooks:
24+
- id: bandit
25+
args: ["-r", "dodiscover"]
26+
- repo: https://github.com/PyCQA/flake8
27+
rev: "6.0.0"
28+
hooks:
29+
- id: flake8
30+
- repo: https://github.com/pre-commit/mirrors-mypy
31+
rev: "v0.971"
32+
hooks:
33+
- id: mypy
34+
name: mypy (dodiscover)
35+
args: ["--config-file", "pyproject.toml"]
36+
files: ^dodiscover/
37+
- repo: https://github.com/pre-commit/mirrors-mypy
38+
rev: "v0.971"
39+
hooks:
40+
- id: mypy
41+
name: mypy (tests)
42+
args: ["--config-file", "pyproject.toml"]
43+
files: ^tests/
44+

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ Finally, you should run some mypy type checks:
162162

163163
poetry run poe type_check
164164

165+
### Pre-commit Hooks
166+
167+
To improve development workflows, you can use pre-commit hooks that automatically check for all of the `poe` tasks above:
168+
169+
pre-commit install
170+
171+
Whenever a commit is performed, these hooks will run to ensure that the code satisfies all formatting, style, and test checks.
172+
165173
### Documentation
166174

167175
If you need to build the documentation locally and check for doc errors:
@@ -174,4 +182,4 @@ If you need to add new, or remove old dependencies, then you need to modify the
174182

175183
poetry update
176184

177-
To update the lock file.
185+
To update the lock file.

docs/whats_new/v0.1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Changelog
4242
- |Feature| Implement export/import functions to go to/from pywhy-graphs to causallearn and to/from pywhy-graphs to numpy, by `Adam Li`_ (:pr:`51`)
4343
- |Feature| Implement export/import functions to go to/from pywhy-graphs to pcalg and tetrad, by `Adam Li`_ (:pr:`60`)
4444
- |Feature| Implement export/import functions to go to/from pywhy-graphs to ananke-causal, by `Jaron Lee`_ (:pr:`63`)
45+
- |Feature| Implement pre-commit hooks for development, by `Jaron Lee`_ (:pr:`68`)
4546

4647
Code and Documentation Contributors
4748
-----------------------------------

0 commit comments

Comments
 (0)