Skip to content

Commit b48adf2

Browse files
committed
Update contributing documentation
1 parent c6534cc commit b48adf2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/contributing.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,34 @@ You can find the list of bugs, enhancements and feature requests on the
1717
`issue tracker <https://github.com/jazzband/django-oauth-toolkit/issues>`_. If you want to fix an issue, pick up one and
1818
add a comment stating you're working on it.
1919

20+
Code Style
21+
==========
22+
23+
The project uses `flake8 <https://flake8.pycqa.org/en/latest/>`_ for linting,
24+
`black <https://black.readthedocs.io/en/stable/>`_ for formatting the code,
25+
`isort <https://pycqa.github.io/isort/>`_ for formatting and sorting imports,
26+
and `pre-commit <https://pre-commit.com/>`_ for checking/fixing commits for
27+
correctness before they are made.
28+
29+
You will need to install ``pre-commit`` yourself, and then ``pre-commit`` will
30+
take care of installing ``flake8``, ``black`` and ``isort``.
31+
32+
After cloning your repository, go into it and run::
33+
34+
pre-commit install
35+
36+
to install the hooks. On the next commit that you make, ``pre-commit`` will
37+
download and install the necessary hooks (a one off task). If anything in the
38+
commit would fail the hooks, the commit will be abandoned. For ``black`` and
39+
``isort``, any necessary changes will be made automatically, but not staged.
40+
Review the changes, and then re-stage and commit again.
41+
42+
Using ``pre-commit`` ensures that code that would fail in QA does not make it
43+
into a commit in the first place, and will save you time in the long run. You
44+
can also (largely) stop worrying about code style, although you should always
45+
check how the code looks after ``black`` has formatted it, and think if there
46+
is a better way to structure the code so that it is more readable.
47+
2048
Pull requests
2149
=============
2250

0 commit comments

Comments
 (0)