diff options
| author | 2023-12-18 02:36:54 +0800 | |
|---|---|---|
| committer | 2023-12-18 02:36:54 +0800 | |
| commit | 5ba9f3557d6359c8041c9928e9b2f567286a4f74 (patch) | |
| tree | 44ae7957062b751f90a616eeab7bd8775cb1ac9a | |
| parent | 0c83593d99afdff01f96d304369156687069fc44 (diff) | |
| download | infini-5ba9f3557d6359c8041c9928e9b2f567286a4f74.tar.gz infini-5ba9f3557d6359c8041c9928e9b2f567286a4f74.zip | |
feat(typing): add `StateT` type var
| -rw-r--r-- | src/infini/handler.py | 7 | ||||
| -rw-r--r-- | src/infini/typing.py | 5 |
2 files changed, 11 insertions, 1 deletions
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 |
