pre-commit updates with Ruff#2184
Conversation
AndreasArvidsson
left a comment
There was a problem hiding this comment.
Looks good. Just had one small change I think we need to make.
Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com>
Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com>
|
CI is happy now. I ran into an issue with |
Remove unnecessary comments.
for more information, see https://pre-commit.ci
| # Want to use pyproject instead of toml, but pre-commit.ci doesn't yet support it. | ||
| types_or: [python, toml] |
There was a problem hiding this comment.
FWIW pre-commit.ci always runs pre-commit run -a so the hook would always run in CI anyway.
There was a problem hiding this comment.
Sorry, not sure how that addresses my concern. The issue is if I use types_or: [python, pyproject] to limit the types of files that Ruff evaluates, pre-commit.ci barfs because it does not use a new enough version of identify — see pre-commit-ci/issues#265. I'll try to get a PR submitted today to get this fixed as requested (update: done and merged; I'll try this again next week as not sure how long it takes for the production service to be updated).
There was a problem hiding this comment.
If you don't specify this at all ruff would still check (by necessity) the pyproject.toml, wouldn't it?
There was a problem hiding this comment.
The Ruff pre commit hook specifies by default types_or: [python, pyi, jupyter] so I don't think so.
https://github.com/astral-sh/ruff-pre-commit/blob/6fec9b7edb08fd9989088709d864a7826dc74e80/.pre-commit-hooks.yaml#L6
There was a problem hiding this comment.
The types_or tells pre-commit what files to collect and pass to the hook. But ruff needs to read pyproject.toml since that's how you configure ruff in the first place. So it should report issues with parsing its own config regardless?
Sure, adding it here would mean that a local pre-commit run (or prek run) will rerun ruff if you change the pyproject.toml (without touching any Python files). But that will never be an issue for CI.
From the Community Backlog session — we are using a combination of pre-commit hooks which are no longer supported, no longer relevant, slow or have newer/better alternatives.
this is in use for JavaScript, CSS, JSON, etc. — probably for JSON/YAML/Markdown. The repository above is archived and we should find an alternative. @AndreasArvidsson recommends we give oxc a look.
I think we can remove this entirely as it's there to support migration to Python 3.6 string formatting.
these two can be replaced by Ruff, as in this PR.