piratar / wasa2il

Direct democracy system
https://x.piratar.is
Other
28 stars 16 forks source link

Running the black code formatter on the codebase #241

Open tomage opened 2 years ago

tomage commented 2 years ago

EDIT: This is really a tiny PR - should take about 5 mins to review I promise :)


Right.. This is a big one! But also, a small one.

It's big because it changes a lot of files, and it may introduce coding styles foreign to some developers.

It's small because functionally, the code is exactly the same. Black is written by one of the core contributors to python, and he did a clever thing with black: It compares the AST (abstract syntax tree) of the code before and after, and makes sure it's the same. This pretty much makes sure that the code functions the same. Hence, this patch is actually small.

**The only files that need any reviewing here are:

pyproject.toml is nice. It can be used to configure other aspects of our python projects later on. Read more about it here: https://peps.python.org/pep-0621/ and here: https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/.

All of the other files are .py files changed by black, and thus need no reviewing, unless if the reader is curious how black is formatting the files.

tomage commented 2 years ago

To add: I do want to put in some pre-push git hook to prevent the code from being de-blackified, but I've also found that it's good to do this a bit after blackifying the codebase, so as to not stir things up too much.

Once (if?) we do add such a hook (for example via the pre-commit.com mechanism), there might be some files that will have gone out-of-black format, but it's no big deal to blackify them along with adding the hook.