mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 19:11:00 +00:00
add types
This commit is contained in:
@ -2,14 +2,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from types import ModuleType
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import NoReturn, TYPE_CHECKING
|
||||
from typing import Any, Set, List, Dict, Type, Tuple, Mapping
|
||||
from typing import Union, Optional, Iterable, Callable, Awaitable
|
||||
from typing import Union, TypeVar, Optional, Iterable, Callable, Awaitable
|
||||
|
||||
# import some modules needed when checking types
|
||||
if TYPE_CHECKING:
|
||||
from nonebot.adapters import BaseBot as Bot
|
||||
from nonebot.event import Event
|
||||
from nonebot.event import Event as EventClass
|
||||
from nonebot.matcher import Matcher as MatcherClass
|
||||
from nonebot.drivers import BaseDriver, BaseWebSocket
|
||||
from nonebot.adapters import BaseBot, BaseMessage, BaseMessageSegment
|
||||
|
||||
|
||||
def overrides(InterfaceClass: object):
|
||||
@ -22,4 +24,17 @@ def overrides(InterfaceClass: object):
|
||||
return overrider
|
||||
|
||||
|
||||
Handler = Callable[["Bot", "Event", dict], Awaitable[None]]
|
||||
Driver = TypeVar("Driver", bound="BaseDriver")
|
||||
WebSocket = TypeVar("WebSocket", bound="BaseWebSocket")
|
||||
|
||||
Bot = TypeVar("Bot", bound="BaseBot")
|
||||
Event = TypeVar("Event", bound="EventClass")
|
||||
Message = TypeVar("Message", bound="BaseMessage")
|
||||
MessageSegment = TypeVar("MessageSegment", bound="BaseMessageSegment")
|
||||
|
||||
PreProcessor = Callable[[Bot, Event], Union[Awaitable[None],
|
||||
Awaitable[NoReturn]]]
|
||||
|
||||
Matcher = TypeVar("Matcher", bound="MatcherClass")
|
||||
Handler = Callable[["Bot", Event, dict], Union[Awaitable[None],
|
||||
Awaitable[NoReturn]]]
|
||||
|
Reference in New Issue
Block a user