MAINT: Use ruff-format instead of running black in pre-commit#16029
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
neutrinoceros
left a comment
There was a problem hiding this comment.
I think it is customary to log large formatting commits in .git-blame-ignore-revs so they don't show up in git blame
|
We do have that file from when we initially implemented https://github.com/astropy/astropy-APEs/blob/main/APE20.rst but since then, we have not been adding follow-up ruff/black updates to it. Regardless, I don't think we can do this until we get the final merge commit after merging this PR? Anyways, if you want something added to https://github.com/astropy/astropy/blob/main/.git-blame-ignore-revs , either we do follow-up PR or I can do it directly on |
eerovaher
left a comment
There was a problem hiding this comment.
- #15998 should be merged before we start working on this.
- We have configured Black to ignore
docs/andexamples/. I think it would be a good idea to start formatting Python code in those directories too, but not in this pull request. - If we are not using Black anymore then all the Black configuration in
pyproject.tomlshould be converted to equivalent Ruff formatter configuration. - Our developer documentation needs to be updated.
Only if we squash merge, but as you said, it can be done in a follow up ! |
WilliamJamieson
left a comment
There was a problem hiding this comment.
The modeling changes look like an actual improvement.
There was a problem hiding this comment.
cosmology & units both LGTM!
Also +1 to @eerovaher's list.
I will open a new PR for that. Copied over the black exclude list to ruff format too.
Done.
I have updated it in the places I saw black pop up. I have still put in links to the OG black style guide as ruff format wants to use that as the base and not deviate too much from it and the black docs explain it much better than ruff's docs. |
mhvk
left a comment
There was a problem hiding this comment.
Mostly changes for the better, except for two mathematics one. I think that should be reported upstream as undesirable.
| # ISC001 shouldn't be used with ruff format | ||
| # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules | ||
| "ISC001", |
There was a problem hiding this comment.
It's best to keep the list of ignored rules in alphabetical order. Admittedly RUF005 is in the wrong place too, but this pull request shouldn't worry about that (and I'm not convinced that RUF005 belongs on this list anyways).
There was a problem hiding this comment.
Done! Well I would argue as soon as we want to keep the things in order here, we should have a formatter tool :)
Time for pyproject-fmt?
eerovaher
left a comment
There was a problem hiding this comment.
This is now ready to be squashed and merged.
|
Not so fast, 3 warnings in doc build: |
eerovaher
left a comment
There was a problem hiding this comment.
The documentation build succeeds, so this really should be ready to be squashed and merged.
|
7 approvals! This must be a record. 😸 |
* MAINT: Use ruff-format instead of running black in pre-commit * use ruff link

This resolves #15757 as astropy/astropy-APEs#90 has been accepted.
c69079e has the changes caused by this.