CI: Swap in ruff for black and flake8 20/72920/1
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Tue, 4 Jun 2024 13:35:21 +0000 (06:35 -0700)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Tue, 4 Jun 2024 13:35:21 +0000 (06:35 -0700)
* ruff runs significantly faster than black and flake8 and is a single
  tool instead of two separate tools
* Fix the bandit configuration to properly exclude all test files

Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
Change-Id: I1d5d321f35cb56f669ec1b02097c1e7f2e21f94f

.pre-commit-config.yaml

index 6a5ec0c..8eba625 100644 (file)
@@ -16,24 +16,22 @@ repos:
     hooks:
       - id: gitlint
 
-  - repo: https://github.com/ambv/black
-    rev: 23.3.0
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+    rev: fc609d3ce5e38f1d32423050196bf0ce4ecc59c1  # frozen: v0.4.5
     hooks:
-      - id: black
+      - id: ruff
+        files: ^(docs)/.+\.py$
+        args: [--fix, --exit-non-zero-on-fix]
+      - id: ruff-format
+        files: ^(docs)/.+\.py$
 
-  - repo: https://github.com/PyCQA/flake8
-    rev: 6.0.0
-    hooks:
-      - id: flake8
-        args: ["--max-line-length=120"]
-        additional_dependencies: [Flake8-pyproject]
 
   - repo: https://github.com/pycqa/bandit
     rev: 1.7.5
     hooks:
       - id: bandit
         # Bandit does not need to run on test code
-        exclude: tests/*
+        exclude: tests/.*
 
   - repo: https://github.com/pycqa/pydocstyle
     rev: 6.3.0