# Code formatting with Black, read this to avoid messy merge conflicts

**URL:** https://we.hypha.app/t/code-formatting-with-black-read-this-to-avoid-messy-merge-conflicts/461
**Category:** 📢 Announcements
**Created:** [August 31, 2023, 1:08pm UTC](https://we.hypha.app/t/code-formatting-with-black-read-this-to-avoid-messy-merge-conflicts/461 "2023-08-31T13:08:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![frjo](https://yyz2.discourse-cdn.com/flex036/user_avatar/we.hypha.app/frjo/32/5_2.png) [@frjo](https://we.hypha.app/u/frjo)
#### Post date: [August 31, 2023, 1:08pm UTC](https://we.hypha.app/t/code-formatting-with-black-read-this-to-avoid-messy-merge-conflicts/461/1 "2023-08-31T13:08:14Z")

</div>

We are starting to enforce code styling with black, prettier and djhtml in Hypha.

The changes are not big but will touch _many_ files. See PRs below.

We suggest other organisation run `pre-commit run --all-files` on their code base before trying to merge in changes after PR #3547 are merged in to main.

> <https://github.com/HyphaApp/hypha/pull/3547>
>
> Add black and prettier check to lint

> <https://github.com/HyphaApp/hypha/pull/3502>
>
> \- Add black, djhtml, prettier
> \- Add precommit
> 
> 
> This PR add configurations f…or black, djhtml and prettier.
> 
> \- black is used for formatting python files
> \- djhtml for formatting html files. Use \`{# fmt: off #}\` and \`{# fmt: on #}\` where needed.
> \- prettier for formatting of sass,css,yml and js files
> 
> Note: prettier picks up some of it's config from \`.editorconfig\`, so it's updated appropriately
> 
> Formating of mardown files, minified or vendored js files are ignored.
> 
> Formatting used off-the-self rules for better consistency with the community as large.
> 
> The formatting is not applied to all the files as it will introduce a lot of merge conflict with
> current PRs, instead \`pre-commit\` config is provide which can be installed by \`precommit install\` 
> locally. It will format only the modified files in the PR/commits. 
> 
> Once majority of the current active PRs are either rebased & formatted using precommit or merged, we can
> run the \`make fmt\` on the full repo and activate additional prettier and black checks in our lint rules.
> 
> The modified sass files fixes the eslint error that would came up if we were to apply the prettier formatter on them. 
> 
> Fixes #3500

---

<div class="post-metadata">

### Author: ![frjo](https://yyz2.discourse-cdn.com/flex036/user_avatar/we.hypha.app/frjo/32/5_2.png) [@frjo](https://we.hypha.app/u/frjo)
#### Post date: [September 8, 2023, 8:41am UTC](https://we.hypha.app/t/code-formatting-with-black-read-this-to-avoid-messy-merge-conflicts/461/2 "2023-09-08T08:41:17Z")

</div>

This PR is now merged, time to run `pre-commit run --all-files` and then rebase all your forks and PRs.
