Skip to content

Commit

Permalink
style: 更新 ruff 和 pyright 配置 (#329)
Browse files Browse the repository at this point in the history
新增 flake8-type-checking 规则,并更新 ruff 版本。
  • Loading branch information
he0119 authored Dec 18, 2024
1 parent d847598 commit 98d5fe9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 2 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ ci:
autoupdate_commit_msg: "chore: auto update by pre-commit hooks"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.8.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
stages: [pre-commit]
args: [--fix]
- id: ruff-format

- 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: [pre-commit]
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ store-test = "python -m src.providers.store_test"
docker-test = "python -m src.providers.docker_test"

[tool.pyright]
pythonVersion = "3.12"
pythonVersion = "3.13"
pythonPlatform = "All"
typeCheckingMode = "standard"

[tool.ruff]
line-length = 88
target-version = "py312"
target-version = "py313"

[tool.ruff.lint]
select = [
"F", # Pyflakes
"F", # pyflakes
"W", # pycodestyle warnings
"E", # pycodestyle errors
"UP", # pyupgrade
Expand All @@ -71,13 +71,13 @@ select = [
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"TC", # flake8-type-checking
"RUF", # Ruff-specific rules
"I", # isort
]
ignore = [
"E402", # module-import-not-at-top-of-file
"E501", # line-too-long
"UP037", # quoted-annotation
"RUF001", # ambiguous-unicode-character-string
"RUF002", # ambiguous-unicode-character-docstring
"RUF003", # ambiguous-unicode-character-comment
Expand Down
6 changes: 4 additions & 2 deletions src/providers/validation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""验证数据是否符合规范"""

from typing import Any
from typing import TYPE_CHECKING, Any

from pydantic import ValidationError
from pydantic_core import ErrorDetails

from .models import (
AdapterPublishInfo,
Expand All @@ -16,6 +15,9 @@
from .models import ValidationDict as ValidationDict
from .utils import translate_errors

if TYPE_CHECKING:
from pydantic_core import ErrorDetails

validation_model_map: dict[PublishType, type[PublishInfoModels]] = {
PublishType.BOT: BotPublishInfo,
PublishType.ADAPTER: AdapterPublishInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/providers/validation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def resolve_adapter_name(name: str) -> str:

def translate_errors(errors: list["ErrorDetails"]) -> list["ErrorDetails"]:
"""翻译 Pydantic 错误信息"""
new_errors: list["ErrorDetails"] = []
new_errors: list[ErrorDetails] = []
for error in errors:
translation = MESSAGE_TRANSLATIONS.get(error["type"])
if translation:
Expand Down

0 comments on commit 98d5fe9

Please sign in to comment.