From da3ac7acb32c377a7bfbae539f50049405e6b5f7 Mon Sep 17 00:00:00 2001 From: 283375 Date: Thu, 20 Jun 2024 21:26:39 +0800 Subject: [PATCH] using ruff as formatter & linter --- .pre-commit-config.yaml | 13 ++++++------- pyproject.toml | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 273404c..b932d10 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.9 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 131fa37..8ad189a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,19 +24,35 @@ classifiers = [ "Homepage" = "https://github.com/ArcaeaOffline/client-pyside6" "Bug Tracker" = "https://github.com/ArcaeaOffline/client-pyside6/issues" -[tool.black] -force-exclude = ''' -( - ui/designer - | .*_ui.py - | .*_rc.py -) -''' +[tool.ruff] +exclude = ["*_ui.py", "*_rc.py"] -[tool.isort] -profile = "black" -extend_skip = ["ui/designer"] -extend_skip_glob = ["*_ui.py", "*_rc.py"] +[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 + "N802", # invalid-function-name + "N803", # invalid-argument-name + "N806", # non-lowercase-variable-in-function + "N815", # mixed-case-variable-in-class-scope + "N816", # mixed-case-variable-in-global-scope +] [tool.pyright] ignore = ["**/__debug*.*"]