CHORE: Upgrade ruff to ~0.12.8 (#2734)

Subjectively, there have been more issues recently with contributor PRs
being rejected by ruff. This could possibly be caused by them using a
different ruff version (presumably: more recent). This PR upgrades ruff
to the latest version to hopefully reduce these issues.

The only change needed to make this ruff version pass was to disable
UP045. This rule requires changing code like:

x: Optional[int]

into

x: int | None

in 220 places. Personally, I don't think it's crucial. Moreover, ruff
won't fix this automically, except with --unsafe-fixes (note that Python
3.9 needs a __future__ import for this, so that could be the reason). My
preference is thus just to disable the rule, but LMK if you disagree.
This commit is contained in:
Benjamin Bossan
2025-08-14 18:03:38 +02:00
committed by GitHub
parent 47961bb547
commit eb1a25abfb
3 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.2
rev: v0.12.8
hooks:
- id: ruff
args:

View File

@ -27,6 +27,7 @@ ignore = [
"F841", # unused variable
"UP007", # X | Y style Unions
"C420", # dict.fromkeys
"UP045", # don't force replacing Optional[X] with X | None
]
[tool.ruff.lint.isort]

View File

@ -21,7 +21,7 @@ extras = {}
extras["quality"] = [
"black", # doc-builder has an implicit dependency on Black, see huggingface/doc-builder#434
"hf-doc-builder",
"ruff~=0.9.2",
"ruff~=0.12.8",
]
extras["docs_specific"] = [
"black", # doc-builder has an implicit dependency on Black, see huggingface/doc-builder#434