grackle-project / grackle

The Grackle chemistry and cooling library for astrophysical simulations and models.
Other
26 stars 50 forks source link

Code formatting #222

Open mabruzzo opened 2 months ago

mabruzzo commented 2 months ago

Overview

As a followup to #218, This introduced a basic configuration file for the pre-commit software that calls clang-format and ruff run code-formatting on all new c/c++/python files added to grackle. All existing files will not be touched. (with that said, I tested out the new c/c++ linting on src/clib/utils.c and src/clib/utils.h since they are unlikely to have merge conflicts).

I also added documentation explaining how to locally run this machinery.

We are interested in using pre-commit.ci, which is a continuous integration system designed around pre-commit.

yt actually makes use of pre-commit.ci

What we need to do after merging

We will need to go to the pre-commit.ci and enable it for the grackle repository. (I'm happy to try to do that, but I may not have appropriate permissions -- so Britton may ultimately need to do that)

mabruzzo commented 1 month ago

I made a few tweaks based on the work I had done while creating similar a similar PR for Enzo-E (in enzo-project/enzo-e#420)

These changes include:

[^1]: Once we merge #208, we should move the contents of .ruff.toml into the [tool.ruff] section of the pyproject.toml file that will be introduced. [^2]: I also needed to bump the clang-format version used during linting (the previously pinned version didn't know about the .clang-format-ignore file)

mabruzzo commented 6 days ago

I added a 3.4 milestone to this (but we can change it). My primary motivation for doing this was Britton's idea that we could start more broadly applying formatting after the next release.