From 5ba9f3557d6359c8041c9928e9b2f567286a4f74 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Mon, 18 Dec 2023 02:36:54 +0800 Subject: feat(typing): add `StateT` type var --- src/infini/handler.py | 7 ++++++- src/infini/typing.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/infini/handler.py b/src/infini/handler.py index 8406972b..dbec3eaf 100644 --- a/src/infini/handler.py +++ b/src/infini/handler.py @@ -7,6 +7,7 @@ from abc import ABCMeta, abstractmethod from enum import Enum +from typing import ClassVar, Optional from .event import MatcherEvent, InfiniEvent __all__ = ["Handler", "HandlerLoadType"] @@ -25,7 +26,11 @@ class Handler: """规则包业务基类""" name: str - priority: int = 0 + priority: ClassVar[int] = 0 + block: ClassVar[bool] = False + + def __init_state__(self) -> Optional[StateT]: + """初始化规则包状态。""" def __init__(self) -> None: pass diff --git a/src/infini/typing.py b/src/infini/typing.py index 9af61569..08015b0e 100644 --- a/src/infini/typing.py +++ b/src/infini/typing.py @@ -8,3 +8,8 @@ from typing import ( NoReturn as NoReturn, Awaitable as Awaitable, ) + +if TYPE_CHECKING: + from typing import Any + +StateT = TypeVar("StateT") \ No newline at end of file -- cgit v1.2.3-70-g09d2