Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 059aa75

Browse files
committed
Updated contributing instructions with black/pre-commit section
1 parent 8ee3e98 commit 059aa75

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

contributing.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,32 @@ Here's what you need to know: changes to any files inside the following director
6464
- `packages/python/chart-studio/chart_studio/plotly/chunked_requests`
6565
- `packages/python/plotly/plotly/matplotlylib/mplexporter`
6666

67+
### Configure black code formatting
68+
This repo uses the [Black](https://black.readthedocs.io/en/stable/) code formatter,
69+
and the [pre-commit](https://pre-commit.com/) library to manage a git commit hook to
70+
run Black prior to each commit. Both pre-commit and black are included in the
71+
`packages/python/plotly/optional-requirements.txt` file, so you should have them
72+
installed already if you've been following along.
73+
74+
To enable the Black formatting git hook, run the following from within your virtual
75+
environment.
76+
77+
```bash
78+
(plotly_dev) $ pre-commit install
79+
```
80+
81+
Now, whenever you perform a commit, the Black formatter will run. If the formatter
82+
makes no changes, then the commit will proceed. But if the formatter does make changes,
83+
then the commit will abort. To proceed, stage the files that the formatter
84+
modified and commit again.
85+
86+
If you don't want to use `pre-commit`, then you can run black manually prior to making
87+
a PR as follows.
88+
89+
```bash
90+
(plotly_dev) $ black .
91+
```
92+
6793
### Making a Development Branch
6894

6995
Third, *don't* work in the `master` branch. As soon as you get your master branch ready, run:

0 commit comments

Comments
 (0)