From effe9092636acd9950d2d698390b52a6ff79527d Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:51:43 +0200 Subject: [PATCH] STY: Enforce ruff rules Disable some rules and postpone fixes. --- .pre-commit-config.yaml | 5 +++ pyproject.toml | 83 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1bda308da..072542a218 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,11 @@ repos: rev: 24.2.0 hooks: - id: black + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.9 + hooks: + - id: ruff + args: ["--fix", "--show-source"] - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: diff --git a/pyproject.toml b/pyproject.toml index 2b1282eb74..04c01777a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,3 +25,86 @@ doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE ELLIPSIS" env = "PYTHONHASHSEED=0" filterwarnings = ["ignore::DeprecationWarning"] junit_family = "xunit2" + +[tool.ruff] +line-length = 88 # same as black + +[tool.ruff.lint] +extend-select = [ + "B", + "C4", + "FLY", + "FURB", + "PERF", + "PGH", + "PIE", + "PLE", + "PT", + "PYI", + "Q", + "RSE", + "RUF", + "UP", +] +ignore = [ + "B006", # requires annotations + "B011", + "B017", # TODO: enable rule + "B020", # TODO: enable rule + "B028", + "B904", + "C401", + "C408", + "C420", # TODO: enable rule + "E402", + "E722", + "E731", # TODO: enable rule + "F401", + "F403", + "F811", + "F841", + "FURB101", + "FURB103", + "FURB113", + "FURB118", # TODO: enable rule + "FURB140", # TODO: enable rule + "FURB171", # TODO: enable rule + "PGH003", # TODO: enable rule + "PGH004", # TODO: enable rule + "PERF203", + "PIE790", + "PIE794", + "PT001", + "PT004", # deprecated + "PT005", # deprecated + "PT011", + "PT015", # TODO: enable rule + "PT017", # TODO: enable rule + "PT018", + "PT019", # TODO: enable rule + "PT021", # TODO: enable rule + "PYI024", + "RUF002", + "RUF005", + "RUF012", # requires annotations + "RUF015", + "UP027", # deprecated + "UP031", # TODO: enable rule + "UP032", # TODO: enable rule + "UP038", # https://github.com/astral-sh/ruff/issues/7871 + # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + "W191", + "E111", + "E114", + "E117", + "D206", + "D300", + "Q000", + "Q001", + "Q002", + "Q003", + "COM812", + "COM819", + "ISC001", + "ISC002", +]