Skip to content

Commit ee686e2

Browse files
authored
Merge pull request #2 from broadinstitute/ruff
Add pre-commit + ruff instructions
2 parents 2e4c6a4 + 865ca83 commit ee686e2

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

.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/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: check-added-large-files
7+
args: ['--maxkb=10240']
8+
- repo: https://github.com/astral-sh/ruff-pre-commit
9+
rev: v0.7.2
10+
hooks:
11+
- id: ruff
12+
types_or: [ python, pyi ]
13+
args: [ --fix ]
14+
- id: ruff-format
15+
types_or: [ python, pyi ]

.ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

01-lab-notebook.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ Pull Requests:
3131

3232
- Use for most analyses (rmd, jupytext, ipynb)
3333
- Use scripts for computationally intensive tasks
34-
- Format code with ruff
35-
- Follow [Google's Python Style Guide](https://google.github.io/styleguide/pyguide.html)
34+
- Format code with ruff (see [Best Practices](#best-practices))
3635

3736
## Data Management
3837

3938
Use DVC for data versioning.
39+
4040
For large/dynamic datasets:
4141

4242
1. Create separate `-data` repository with the same base name as the main project
@@ -82,8 +82,13 @@ For large/dynamic datasets:
8282

8383
## Best Practices
8484

85-
- Use .gitignore and precommit hooks
86-
- No large files in main repository
85+
- Use `.gitignore`
86+
- Use [precommit hooks](https://pre-commit.com/) (see webpage for local installation instructions)
87+
- Use [`.pre-commit-config.yaml`](.pre-commit-config.yaml) as the starting point
88+
- Run `pre-commit run --all-files` locally
89+
- Install precommit CI on your repo <https://pre-commit.ci/>
90+
- Use [ruff](https://github.com/charliermarsh/ruff) to enforce code style
91+
At present, we use the default settings, so `.ruff.toml` is not required, but we have included and empty config for completeness (and `.pre-commit-config.yaml` requires it)
8792

8893
## Addressing Pitfalls
8994

0 commit comments

Comments
 (0)