Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update contributing.rst to talk about pre-commit #2765

Merged
merged 3 commits into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,31 @@ Code formatting
~~~~~~~~~~~~~~~

Instead of wasting time arguing about code formatting, we use `black
<https://github.com/psf/black>`__ to automatically format all our
code to a standard style. While you're editing code you can be as
sloppy as you like about whitespace; and then before you commit, just
run::
<https://github.com/psf/black>`__ as well as other tools to automatically
format all our code to a standard style. While you're editing code you
can be as sloppy as you like about whitespace; and then before you commit,
just run::

pip install -U black
black setup.py trio
pip install -U pre-commit
pre-commit

to fix it up. (And don't worry if you forget – when you submit a pull
request then we'll automatically check and remind you.) Hopefully this
will let you focus on more important style issues like choosing good
names, writing useful comments, and making sure your docstrings are
nicely formatted. (black doesn't reformat comments or docstrings.)

If you would like, you can even have pre-commit run before you commit by
running::

pre-commit install

and now pre-commit will run before git commits. You can uninstall the
pre-commit hook at any time by running::

pre-commit uninstall


Very occasionally, you'll want to override black formatting. To do so,
you can can add ``# fmt: off`` and ``# fmt: on`` comments.
CoolCat467 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -311,6 +322,11 @@ If you want to see what changes black will make, you can use::
in-place.)


Additionally, in some cases it is necessary to disable isort changing the
order of imports. To do so you can add ``# isort: split`` comments.
For more information, please see `isort's docs <https://pycqa.github.io/isort/docs/configuration/action_comments.html>`__.


.. _pull-request-release-notes:

Release notes
Expand Down