urbanopt / geojson-modelica-translator

GeoJSON to Modelica Translator that is focused on district energy system design and analysis.
https://www.nrel.gov/buildings/urbanopt.html
Other
18 stars 11 forks source link

Update tooling to use ruff for linting & formatting #619

Closed vtnate closed 6 months ago

vtnate commented 7 months ago

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 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.

nllong commented 6 months ago

@vtnate this looks great. Can you fix the conflicting files and then I'll review again?!