From 231d7f47e51bbdc3bd8178352fe1065380225f54 Mon Sep 17 00:00:00 2001
From: Doug Goldstein <cardoe@cardoe.com>
Date: Fri, 6 Dec 2024 10:20:20 -0600
Subject: [PATCH] enable ruff in pre-commit with some initial lints

Used pycodestyle, pyflakes, flake8-logging-format, and flake8-logging to
bring ruff to the ironic tree.

Change-Id: I4e355b0d2cf065f8844794b14474c34b65e7562b
Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
---
 .pre-commit-config.yaml |  5 +++++
 pyproject.toml          | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index cfaeb61c55..fc29f02e6a 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -80,6 +80,11 @@ repos:
     rev: v1.1.2
     hooks:
       - id: doc8
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+    rev: v0.7.3
+    hooks:
+      - id: ruff
+        args: ['--fix', '--unsafe-fixes']
   - repo: local
     hooks:
       - id: check-releasenotes
diff --git a/pyproject.toml b/pyproject.toml
index a9362f7167..99b3dad22e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,3 +4,22 @@ build-backend = "pbr.build"
 
 [tool.doc8]
 ignore = ["D001"]
+
+[tool.ruff]
+line-length = 79
+
+[tool.ruff.lint]
+select = [
+    "E",        # pycodestyle (error)
+    "F",        # pyflakes
+    "G",        # flake8-logging-format
+    "LOG",      # flake8-logging
+]
+
+[tool.ruff.lint.per-file-ignores]
+"ironic/tests/**/*.py" = [
+    "E402",     # module-import-not-at-top-of-file
+]
+"ironic/drivers/modules/drac/raid.py" = [
+    "G003",     # Logging statement uses `+`
+]