Skip to content

Commit 1e95ff7

Browse files
authored
Black for developers (#383)
1 parent 2a36ebd commit 1e95ff7

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

doc/source/contributing_code.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ is not available for your operating system/architecture from your list.
271271
'rdkit>=2020.03.1' \
272272
'scikit-learn' \
273273
'seaborn>=0.7.0' \
274-
'tidynamics>1.0.0'
274+
'tidynamics>1.0.0' \
275+
'black=24'
275276
276277
# documentation dependencies
277278
mamba install -c conda-forge \
@@ -334,7 +335,8 @@ dependencies, do the following:
334335
'scipy>=1.5.0' \
335336
'threadpoolctl' \
336337
'tqdm>=4.43.0' \
337-
'waterdynamics'
338+
'waterdynamics' \
339+
'black=24'
338340
339341
You can also install the following optional dependencies (note that
340342
you will not be able to install all the optional dependencies as
@@ -450,30 +452,30 @@ Writing new code
450452
Code formatting in Python
451453
-------------------------
452454

453-
MDAnalysis is a project with a long history and many contributors; it hasn't used a consistent coding style. Since version 0.11.0, we are trying to update all the code to conform with `PEP8`_. Our strategy is to update the style every time we touch an old function and thus switch to `PEP8`_ continuously.
455+
Since version 0.11.0, we are trying to update all the code to conform with `PEP8`_.
454456

455-
**Important requirements (from PEP8)**:
456-
- keep line length to **79 characters or less**; break long lines sensibly although for readability we may allow longer lines
457-
- indent with **spaces** and use **4 spaces per level**
457+
**Important requirements (from PEP8):**
458458
- naming:
459459

460460
- classes: `CapitalClasses` (i.e. capitalized nouns without spaces)
461461
- methods and functions: `underscore_methods` (lower case, with underscores for spaces)
462462

463463
We recommend that you use a Python Integrated Development Environment (IDE) (`PyCharm`_ and others) or external tools like `flake8`_ for code linting. For integration of external tools with emacs and vim, check out `elpy`_ (emacs) and `python-mode`_ (vim).
464464

465-
To apply the code formatting in an automated way, you can also use code formatters. External tools include `autopep8`_ and `yapf`_. Most IDEs either have their own code formatter or will work with one of the above through plugins.
466-
See :ref:`format-darker` for notes on maintaining code style compliance with existing tools.
465+
MDAnalysis uses `black`_` for automated code formatting, which is bound by the `black stability policy`_. The configuration for `black`_ is provided in the `pyproject.toml` files. To format your code with `black`_, you can run the following commands:
467466

467+
.. code-block:: bash
468+
469+
black package
470+
black testsuite
468471
469472
.. _`PEP8`: https://www.python.org/dev/peps/pep-0008/
470473
.. _`flake8`: http://flake8.readthedocs.org/en/latest/
471474
.. _`PyCharm`: https://www.jetbrains.com/pycharm/
472475
.. _`elpy`: https://github.com/jorgenschaefer/elpy
473476
.. _`python-mode`: https://github.com/klen/python-mode
474-
.. _`autopep8`: https://github.com/hhatto/autopep8
475-
.. _`yapf`: https://github.com/google/yapf
476-
477+
.. _`black`: https://black.readthedocs.io/en/stable/
478+
.. _`black stability policy`: https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy
477479

478480
Modules and dependencies
479481
------------------------

0 commit comments

Comments
 (0)