You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/CONTRIBUTING.md
+39-1Lines changed: 39 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,9 @@ Then install your local fork of nf-core/tools:
33
33
pip install -e .
34
34
```
35
35
36
-
## Code formatting with Black
36
+
## Code formatting
37
+
38
+
### Black
37
39
38
40
All Python code in nf-core/tools must be passed through the [Black Python code formatter](https://black.readthedocs.io/en/stable/).
39
41
This ensures a harmonised code formatting style throughout the package, from all contributors.
@@ -51,6 +53,42 @@ You can also set it up to run when you [make a commit](https://black.readthedocs
51
53
There is an automated CI check that runs when you open a pull-request to nf-core/tools that will fail if
52
54
any code does not adhere to Black formatting.
53
55
56
+
### isort
57
+
58
+
All Python code must also be passed through [isort](https://pycqa.github.io/isort/index.html).
59
+
This ensures a harmonised imports throughout the package, from all contributors.
60
+
61
+
To run isort on the command line recursively on the whole repository you can use:
62
+
63
+
```bash
64
+
isort .
65
+
```
66
+
67
+
isort also has [plugins for most common editors](https://github.com/pycqa/isort/wiki/isort-Plugins)
68
+
to automatically format code when you hit save.
69
+
Or [version control integration](https://pycqa.github.io/isort/docs/configuration/pre-commit.html) to set it up to run when you make a commit.
70
+
71
+
There is an automated CI check that runs when you open a pull-request to nf-core/tools that will fail if
72
+
any code does not adhere to isort formatting.
73
+
74
+
### pre-commit hooks
75
+
76
+
This repository comes with [pre-commit](https://pre-commit.com/) hooks for black, isort and Prettier. pre-commit automatically runs checks before a commit is committed into the git history. If all checks pass, the commit is made, if files are changed by the pre-commit hooks, the user is informed and has to stage the changes and attempt the commit again.
77
+
78
+
You can use the pre-commit hooks if you like, but you don't have to. The CI on Github will run the same checks as the tools installed with pre-commit. If the pre-commit checks pass, then the same checks in the CI will pass, too.
79
+
80
+
You can install the pre-commit hooks into the development environment by running the following command in the root directory of the repository.
81
+
82
+
```bash
83
+
pre-commit install --install-hooks
84
+
```
85
+
86
+
You can also run all pre-commit hooks without making a commit:
87
+
88
+
```bash
89
+
pre-commit run --all
90
+
```
91
+
54
92
## API Documentation
55
93
56
94
We aim to write function docstrings according to the [Google Python style-guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings). These are used to automatically generate package documentation on the nf-core website using Sphinx.
0 commit comments