Auto-formatting C code in astropy

4 views
Skip to first unread message

Thomas Robitaille

unread,
Oct 1, 2025, 5:34:55 AM10/1/25
to astropy-dev mailing list
Hi everyone,

I just wanted to draw your attention to the following issue:


I am proposing enabling clang-format in pre-commit to auto-format C code in astropy core (except for files vendored from other packages such as in cextern). This will save time for people working on C code to avoid having to try and get e.g. all the indentation right and consistent with the rest of each file. We already do auto-formatting for Python code, so this would just be an extension of that.

If you have any opinions about this, please feel free to chime in!

Thanks,
Tom

Clément Robert

unread,
Oct 2, 2025, 2:37:50 AM10/2/25
to astropy-dev
Hi Tom, thanks for proposing this. I think the biggest win from formatting with black (and latter, ruff format) was that we could embrace the defaults and stop discussing formatting (almost) entirely, so, even though clang-format *does* support configuration, I agree with going for defaults all the way.
Clément

Thomas Robitaille

unread,
Mar 13, 2026, 5:43:07 AM (3 days ago) Mar 13
to astro...@googlegroups.com
Hi everyone,

I have updated the pull request to add automated formatting of C code with clang-format:


Following some feedback, I have tweaked the config a little, and the PR reformats all sub-packages except astropy/wcs for now – since that subpackage dominates the number of C lines by far in astropy, it was more productive to do a PR without for now in terms of discussing the config, and that can be reformatted in a separate PR later.

In the interest of not dwelling too long on config tweaks etc, I'd like to propose that if anyone would like to look at the PR and has any feedback, please do so by the end of March 17th – after that, we can merge if there are no objections.

Thanks!
Tom

--
You received this message because you are subscribed to the Google Groups "astropy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astropy-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/astropy-dev/a8387a77-5805-42ff-b863-579f01c23d7dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages