From 2a138504bf8835ca511f675c379a1473168fa1ff Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 19 Aug 2023 21:45:14 -0500 Subject: [PATCH 1/3] Update `contributing.rst` to talk about pre-commit --- docs/source/contributing.rst | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 7d66ae711d..b1d15cf0c6 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. From 766c9815fc09caef13732742bd37e1c978201619 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 19 Aug 2023 21:59:49 -0500 Subject: [PATCH 2/3] Add details about isort action comments --- docs/source/contributing.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index b1d15cf0c6..28f80684cf 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -322,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: skip`` comments. +For more information, please see `isort's docs `__. + + .. _pull-request-release-notes: Release notes From 14f5c12bb68bfe5d0b8af46ea65acce93d31af0e Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Sat, 19 Aug 2023 22:21:52 -0500 Subject: [PATCH 3/3] Prefer `split` instead of `skip` --- docs/source/contributing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 28f80684cf..6189814b3f 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -323,7 +323,7 @@ in-place.) Additionally, in some cases it is necessary to disable isort changing the -order of imports. To do so you can add ``# isort: skip`` comments. +order of imports. To do so you can add ``# isort: split`` comments. For more information, please see `isort's docs `__.