🚨 完全使用 ruff 替代 isort 与 black

This commit is contained in:
BalconyJH 2024-12-10 05:46:17 +08:00
parent 28dd15a950
commit b9f6e740af
No known key found for this signature in database
GPG Key ID: FF602923BD2A1FAF
2 changed files with 24 additions and 42 deletions

View File

@ -1,33 +1,16 @@
default_install_hook_types: [pre-commit, prepare-commit-msg] default_install_hook_types: [pre-commit]
ci: ci:
autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks" autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks"
autofix_prs: true autofix_prs: true
autoupdate_branch: dev autoupdate_branch: master
autoupdate_schedule: weekly autoupdate_schedule: monthly
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks" autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
repos: repos:
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6 rev: v0.8.1
hooks: hooks:
- id: ruff - id: ruff
args: [--fix, --exit-non-zero-on-fix] args: [--fix]
stages: [commit] stages: [pre-commit]
- id: ruff-format
- repo: https://github.com/pycqa/isort stages: [pre-commit]
rev: 5.13.2
hooks:
- id: isort
stages: [commit]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
stages: [commit]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [javascript, jsx, ts, tsx, markdown, yaml, json]
stages: [commit]

View File

@ -40,7 +40,6 @@ psutil = "^5.9.8"
feedparser = "^6.0.11" feedparser = "^6.0.11"
opencv-python = "^4.9.0.80" opencv-python = "^4.9.0.80"
imagehash = "^4.3.1" imagehash = "^4.3.1"
black = "^24.4.2"
cn2an = "^0.5.22" cn2an = "^0.5.22"
aiohttp = "^3.9.5" aiohttp = "^3.9.5"
dateparser = "^1.2.0" dateparser = "^1.2.0"
@ -59,6 +58,9 @@ pytest-mock = "^3.6.1"
pytest-asyncio = "^0.23.5" pytest-asyncio = "^0.23.5"
pytest-xdist = "^3.3.1" pytest-xdist = "^3.3.1"
respx = "^0.21.1" respx = "^0.21.1"
ruff = "^0.8.0"
pre-commit = "^4.0.0"
[tool.nonebot] [tool.nonebot]
plugins = [ plugins = [
@ -75,31 +77,19 @@ adapters = [
{ name = "开黑啦", module_name = "nonebot.adapters.kaiheila" }, { name = "开黑啦", module_name = "nonebot.adapters.kaiheila" },
] ]
[tool.black]
line-length = 88
target-version = ["py39", "py310", "py311", "py312"]
include = '\.pyi?$'
extend-exclude = '''
'''
[tool.isort]
profile = "black"
line_length = 88
length_sort = true
skip_gitignore = true
force_sort_within_sections = true
src_paths = ["zhenxun", "tests"]
extra_standard_library = ["typing_extensions"]
[tool.ruff] [tool.ruff]
line-length = 88 line-length = 88
target-version = "py310" target-version = "py310"
[tool.ruff.format]
line-ending = "lf"
[tool.ruff.lint] [tool.ruff.lint]
select = [ select = [
"F", # Pyflakes "F", # Pyflakes
"W", # pycodestyle warnings "W", # pycodestyle warnings
"E", # pycodestyle errors "E", # pycodestyle errors
"I", # isort
"UP", # pyupgrade "UP", # pyupgrade
"ASYNC", # flake8-async "ASYNC", # flake8-async
"C4", # flake8-comprehensions "C4", # flake8-comprehensions
@ -108,6 +98,7 @@ select = [
"PYI", # flake8-pyi "PYI", # flake8-pyi
"PT", # flake8-pytest-style "PT", # flake8-pytest-style
"Q", # flake8-quotes "Q", # flake8-quotes
"TID", # flake8-tidy-imports
"RUF", # Ruff-specific rules "RUF", # Ruff-specific rules
] ]
ignore = [ ignore = [
@ -118,10 +109,18 @@ ignore = [
"RUF003", # ambiguous-unicode-character-comment "RUF003", # ambiguous-unicode-character-comment
] ]
[tool.ruff.lint.isort]
force-sort-within-sections = true
known-first-party = ["zhenxun", "tests/*"]
extra-standard-library = ["typing_extensions"]
[tool.ruff.lint.flake8-pytest-style] [tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false fixture-parentheses = false
mark-parentheses = false mark-parentheses = false
[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true
[tool.pyright] [tool.pyright]
pythonVersion = "3.10" pythonVersion = "3.10"
pythonPlatform = "All" pythonPlatform = "All"