Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions changelog.d/5537.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add information about how to install and run `black` on the codebase to code_style.rst.
20 changes: 20 additions & 0 deletions docs/code_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,23 @@

- Avoid wildcard imports (``from synapse.types import *``) and relative
imports (``from .types import UserID``).

- **Running ``black`` on your code

The Synapse codebase uses [black](https://pypi.org/project/black/) as an
opinionated code formatter, ensuring all comitted code is properly
formatted.

First install ``black`` with::

pip install --upgrade black

Have ``black`` auto-format your code (it shouldn't change any
functionality) with::

black --check . --exclude="\.tox|build|env"

It's worth noting that modern IDEs and text editors can run ``black``
automatically on save. It may be worth looking into whether this
functionality is supported in your editor for a more convenient development
workflow.