From c81936844532fe4ba445df4b82f358dbf0479e0b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 20 Sep 2024 22:11:12 +0500 Subject: [PATCH] code_style.rst - some notes on black formatting --- .../docs/guides/development/code_style.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bonsai/docs/guides/development/code_style.rst b/src/bonsai/docs/guides/development/code_style.rst index 76a9802c22..8857d6baab 100644 --- a/src/bonsai/docs/guides/development/code_style.rst +++ b/src/bonsai/docs/guides/development/code_style.rst @@ -4,17 +4,18 @@ Code style Black code formatter ------------------------------- -For Python code formatting, we use `Black code formatter `__ with ``--line-length 120``. +For Python code formatting, we use `Black code formatter `__, +black settings are stored in the repository's pyproject.toml. + +We have GitHub workflow `ci-black-formatting` to maintain black formatting across the repository. ``black`` can be installed using ``pip install black`` and files can be formatted with the following example command: .. code-block:: bash - black --line-length 120 src/bonsai/bonsai/bim/module/qto/operator.py + # Format the entire repository. + # Should be used in 99% cases as the entire repository is already formatted using black. + black . + # Format only some specific file. + black src/bonsai/bonsai/bim/module/qto/operator.py -Using PowerShell, you can run the Black formatter on the last commit in the repository. -You can change ``~1`` to ``~n`` to affect ``n`` commits. - -.. code-block:: powershell - - git diff HEAD HEAD~1 --name-only | where {$_ -like "*.py"} | foreach-object { start $_ && black --line-length 120 $_ }