diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 7d66ae711d..6189814b3f 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -286,13 +286,13 @@ Code formatting ~~~~~~~~~~~~~~~ Instead of wasting time arguing about code formatting, we use `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:: +`__ 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 @@ -300,6 +300,17 @@ 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. @@ -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 `__. + + .. _pull-request-release-notes: Release notes