We had a collection of tools being run in pre-commit to lint and format our code. Ruff is the new hotness that replaces all of them and then some and does it faster. I've used it in other packages and I'm a fan.
For many issues (such as long lines) Ruff will usually automatically apply fixes in pre-commit (and not actually commit it, because now something new has changed). For other linting issues Ruff will raise the issue but not actually do anything if it deems the fix "unsafe", presumably meaning the fix is usually but not guaranteed to be the right thing to do.
I briefly considered an alternative modelica-formatting repo for pre-commit, but it only works on mo-files (can't handle our modelica templates) so I abandoned that idea and kept the existing formatter.
Type-checking and dead code detection are on the roadmap for ruff in the future.
What does this PR accomplish?
Replace a variety of pre-commit repos with Ruff
Run Ruff which made a bunch of automatic changes and requested additional manual changes
Future code additions will be subject to this "stricter" formatting & linting
The primary changes are in .pre-commit-config.yaml and in pyproject.toml (some deletions from setup.cfg followed). All the other changes are a result of these tooling changes.
How should this be manually tested?
Pull this branch, make an obvious error like a line too long (over 120 characters) and try to commit it.
Any background context you want to provide?
We had a collection of tools being run in pre-commit to lint and format our code. Ruff is the new hotness that replaces all of them and then some and does it faster. I've used it in other packages and I'm a fan.
For many issues (such as long lines) Ruff will usually automatically apply fixes in pre-commit (and not actually commit it, because now something new has changed). For other linting issues Ruff will raise the issue but not actually do anything if it deems the fix "unsafe", presumably meaning the fix is usually but not guaranteed to be the right thing to do.
I briefly considered an alternative modelica-formatting repo for pre-commit, but it only works on mo-files (can't handle our modelica templates) so I abandoned that idea and kept the existing formatter.
Type-checking and dead code detection are on the roadmap for ruff in the future.
What does this PR accomplish?
The primary changes are in
.pre-commit-config.yaml
and inpyproject.toml
(some deletions fromsetup.cfg
followed). All the other changes are a result of these tooling changes.How should this be manually tested?
Pull this branch, make an obvious error like a line too long (over 120 characters) and try to commit it.