From 38e0d7f8d1c70a23310d9961663ba4f0c3439a7c Mon Sep 17 00:00:00 2001
From: 283375 <bilibili283375@163.com>
Date: Wed, 22 May 2024 01:23:55 +0800
Subject: [PATCH] ci: use ruff as formatter and linter

---
 .github/workflows/test.yml |  2 +-
 .pre-commit-config.yaml    | 13 ++++++-------
 pyproject.toml             | 36 +++++++++++++++++++++++-------------
 requirements.dev.txt       | 10 ++++------
 4 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 85a45d8..587f802 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -21,5 +21,5 @@ jobs:
         with:
           python-version: ${{ matrix.python-version }}
 
-      - run: 'pip install -r requirements.dev.txt .'
+      - run: 'pip install .[dev]'
       - run: 'pytest -v'
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 273404c..20d8ffd 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -4,11 +4,10 @@ repos:
     hooks:
       - id: end-of-file-fixer
       - id: trailing-whitespace
-  - repo: https://github.com/psf/black
-    rev: 23.1.0
+
+  - repo: https://github.com/astral-sh/ruff-pre-commit
+    rev: v0.4.4
     hooks:
-      - id: black
-  - repo: https://github.com/PyCQA/isort
-    rev: 5.12.0
-    hooks:
-      - id: isort
+      - id: ruff
+        args: ["--fix"]
+      - id: ruff-format
diff --git a/pyproject.toml b/pyproject.toml
index 755d9a1..ee1c0cd 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -20,24 +20,34 @@ classifiers = [
   "Programming Language :: Python :: 3",
 ]
 
+[project.optional-dependencies]
+dev = ["ruff~=0.4", "pre-commit~=3.3", "pytest~=7.4", "tox~=4.11"]
+
 [project.urls]
 "Homepage" = "https://github.com/283375/arcaea-offline"
 "Bug Tracker" = "https://github.com/283375/arcaea-offline/issues"
 
-[tool.isort]
-profile = "black"
-src_paths = ["src/arcaea_offline"]
-
 [tool.pyright]
 ignore = ["build/"]
 
-[tool.pylint.main]
-jobs = 0
-
-[tool.pylint.logging]
-disable = [
-  "missing-module-docstring",
-  "missing-class-docstring",
-  "missing-function-docstring",
-  "not-callable", # false positive to sqlalchemy `func.*`, remove this when pylint-dev/pylint(#8138) closed
+[tool.ruff.lint]
+# Full list: https://docs.astral.sh/ruff/rules
+select = [
+  "E",   # pycodestyle (Error)
+  "W",   # pycodestyle (Warning)
+  "F",   # pyflakes
+  "I",   # isort
+  "PL",  # pylint
+  "N",   # pep8-naming
+  "FBT", # flake8-boolean-trap
+  "A",   # flake8-builtins
+  "DTZ", # flake8-datetimez
+  "LOG", # flake8-logging
+  "Q",   # flake8-quotes
+  "G",   # flake8-logging-format
+  "PIE", # flake8-pie
+  "PT",  # flake8-pytest-style
+]
+ignore = [
+  "E501", # line-too-long
 ]
diff --git a/requirements.dev.txt b/requirements.dev.txt
index 7cda2cf..117f92e 100644
--- a/requirements.dev.txt
+++ b/requirements.dev.txt
@@ -1,6 +1,4 @@
-black==23.3.0
-isort==5.12.0
-pre-commit==3.3.1
-pylint==3.0.2
-pytest==7.4.3
-tox==4.11.3
+ruff~=0.4
+pre-commit~=3.3
+pytest~=7.4
+tox~=4.11