Skip to content

Commit fd54141

Browse files
chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.12.1 (#412)
* chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.12.1 * fix: 修复 get_mock_event 函数的类型提示,确保返回类型正确 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: uy/sun <[email protected]>
1 parent 1aacfa4 commit fd54141

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ci:
66
autoupdate_commit_msg: "chore: auto update by pre-commit hooks"
77
repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.11.13
9+
rev: v0.12.1
1010
hooks:
1111
- id: ruff
1212
args: [--fix]

tests/plugins/github/event.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import TypeVar
2+
from typing import cast
33

44
from nonebot.adapters.github import (
55
Adapter,
@@ -10,8 +10,6 @@
1010
PullRequestReviewSubmitted,
1111
)
1212

13-
T = TypeVar("T", bound=Event)
14-
1513
# 事件类型对应的事件名称和事件文件名
1614
EVENT_INFO = {
1715
IssuesOpened: ("issues", "issue-open"),
@@ -24,7 +22,9 @@
2422
}
2523

2624

27-
def get_mock_event(event_type: type[T], filename: str = "", id: str = "1") -> T:
25+
def get_mock_event[T: Event](
26+
event_type: type[T], filename: str = "", id: str = "1"
27+
) -> T:
2828
"""通过事件类型获取事件对象"""
2929

3030
if event_type not in EVENT_INFO:
@@ -38,4 +38,4 @@ def get_mock_event(event_type: type[T], filename: str = "", id: str = "1") -> T:
3838
event = Adapter.payload_to_event(id, event_name, event_path.read_bytes())
3939

4040
assert isinstance(event, event_type)
41-
return event
41+
return cast("T", event)

0 commit comments

Comments
 (0)