删除类型

This commit is contained in:
hemengyang 2022-01-12 18:00:56 +08:00
parent e29db806cc
commit 705a6f7fbf
13 changed files with 48 additions and 195 deletions

View File

@ -27,12 +27,10 @@ class Bot(abc.ABC):
_calling_api_hook: Set[T_CallingAPIHook] = set()
"""
:类型: ``Set[T_CallingAPIHook]``
:说明: call_api 时执行的函数
"""
_called_api_hook: Set[T_CalledAPIHook] = set()
"""
:类型: ``Set[T_CalledAPIHook]``
:说明: call_api 后执行的函数
"""

View File

@ -26,12 +26,10 @@ class MessageSegment(Mapping, abc.ABC, Generic[TM]):
type: str
"""
- 类型: ``str``
- 说明: 消息段类型
"""
data: Dict[str, Any] = field(default_factory=lambda: {})
"""
- 类型: ``Dict[str, Union[str, list]]``
- 说明: 消息段数据
"""

View File

@ -137,7 +137,6 @@ class Env(BaseConfig):
environment: str = "prod"
"""
- **类型**: ``str``
- **默认值**: ``"prod"``
:说明:
@ -163,7 +162,6 @@ class Config(BaseConfig):
# nonebot configs
driver: str = "~fastapi"
"""
- **类型**: ``str``
- **默认值**: ``"~fastapi"``
:说明:
@ -176,7 +174,6 @@ class Config(BaseConfig):
"""
host: IPvAnyAddress = IPv4Address("127.0.0.1") # type: ignore
"""
- **类型**: ``IPvAnyAddress``
- **默认值**: ``127.0.0.1``
:说明:
@ -185,7 +182,6 @@ class Config(BaseConfig):
"""
port: int = 8080
"""
- **类型**: ``int``
- **默认值**: ``8080``
:说明:
@ -194,7 +190,6 @@ class Config(BaseConfig):
"""
log_level: Union[int, str] = "INFO"
"""
- **类型**: ``Union[int, str]``
- **默认值**: ``INFO``
:说明:
@ -215,7 +210,6 @@ class Config(BaseConfig):
# bot connection configs
api_timeout: Optional[float] = 30.0
"""
- **类型**: ``Optional[float]``
- **默认值**: ``30.``
:说明:
@ -226,7 +220,6 @@ class Config(BaseConfig):
# bot runtime configs
superusers: Set[str] = set()
"""
- **类型**: ``Set[str]``
- **默认值**: ``set()``
:说明:
@ -241,7 +234,6 @@ class Config(BaseConfig):
"""
nickname: Set[str] = set()
"""
- **类型**: ``Set[str]``
- **默认值**: ``set()``
:说明:
@ -250,7 +242,6 @@ class Config(BaseConfig):
"""
command_start: Set[str] = {"/"}
"""
- **类型**: ``Set[str]``
- **默认值**: ``{"/"}``
:说明:
@ -259,7 +250,6 @@ class Config(BaseConfig):
"""
command_sep: Set[str] = {"."}
"""
- **类型**: ``Set[str]``
- **默认值**: ``{"."}``
:说明:
@ -268,7 +258,6 @@ class Config(BaseConfig):
"""
session_expire_timeout: timedelta = timedelta(minutes=2)
"""
- **类型**: ``timedelta``
- **默认值**: ``timedelta(minutes=2)``
:说明:

View File

@ -41,17 +41,14 @@ class Driver(abc.ABC):
_adapters: Dict[str, "Adapter"] = {}
"""
:类型: ``Dict[str, Adapter]``
:说明: 已注册的适配器列表
"""
_bot_connection_hook: Set[T_BotConnectionHook] = set()
"""
:类型: ``Set[T_BotConnectionHook]``
:说明: Bot 连接建立时执行的函数
"""
_bot_disconnection_hook: Set[T_BotDisconnectionHook] = set()
"""
:类型: ``Set[T_BotDisconnectionHook]``
:说明: Bot 连接断开时执行的函数
"""
@ -64,26 +61,20 @@ class Driver(abc.ABC):
"""
self.env: str = env.environment
"""
:类型: ``str``
:说明: 环境名称
"""
self.config: Config = config
"""
:类型: ``Config``
:说明: 配置对象
"""
self._clients: Dict[str, "Bot"] = {}
"""
:类型: ``Dict[str, Bot]``
:说明: 已连接的 Bot
"""
@property
def bots(self) -> Dict[str, "Bot"]:
"""
:类型:
``Dict[str, Bot]``
:说明:
获取当前所有已连接的 Bot

View File

@ -168,7 +168,6 @@ class WebSocket(abc.ABC):
@abc.abstractmethod
def closed(self) -> bool:
"""
:类型: ``bool``
:说明: 连接是否已经关闭
"""
raise NotImplementedError

View File

@ -48,90 +48,54 @@ class Config(BaseSettings):
fastapi_openapi_url: Optional[str] = None
"""
:类型:
``Optional[str]``
:说明:
``openapi.json`` 地址默认为 ``None`` 即关闭
"""
fastapi_docs_url: Optional[str] = None
"""
:类型:
``Optional[str]``
:说明:
``swagger`` 地址默认为 ``None`` 即关闭
"""
fastapi_redoc_url: Optional[str] = None
"""
:类型:
``Optional[str]``
:说明:
``redoc`` 地址默认为 ``None`` 即关闭
"""
fastapi_include_adapter_schema: bool = True
"""
:类型:
``bool``
:说明:
是否包含适配器路由的 schema默认为 ``True``
"""
fastapi_reload: bool = False
"""
:类型:
``bool``
:说明:
开启/关闭冷重载
"""
fastapi_reload_dirs: Optional[List[str]] = None
"""
:类型:
``Optional[List[str]]``
:说明:
重载监控文件夹列表默认为 uvicorn 默认值
"""
fastapi_reload_delay: Optional[float] = None
"""
:类型:
``Optional[float]``
:说明:
重载延迟默认为 uvicorn 默认值
"""
fastapi_reload_includes: Optional[List[str]] = None
"""
:类型:
``Optional[List[str]]``
:说明:
要监听的文件列表支持 glob pattern默认为 uvicorn 默认值
"""
fastapi_reload_excludes: Optional[List[str]] = None
"""
:类型:
``Optional[List[str]]``
:说明:
不要监听的文件列表支持 glob pattern默认为 uvicorn 默认值

View File

@ -56,50 +56,30 @@ class Config(BaseSettings):
quart_reload: bool = False
"""
:类型:
``bool``
:说明:
开启/关闭冷重载
"""
quart_reload_dirs: Optional[List[str]] = None
"""
:类型:
``Optional[List[str]]``
:说明:
重载监控文件夹列表默认为 uvicorn 默认值
"""
quart_reload_delay: Optional[float] = None
"""
:类型:
``Optional[float]``
:说明:
重载延迟默认为 uvicorn 默认值
"""
quart_reload_includes: Optional[List[str]] = None
"""
:类型:
``Optional[List[str]]``
:说明:
要监听的文件列表支持 glob pattern默认为 uvicorn 默认值
"""
quart_reload_excludes: Optional[List[str]] = None
"""
:类型:
``Optional[List[str]]``
:说明:
不要监听的文件列表支持 glob pattern默认为 uvicorn 默认值

View File

@ -66,7 +66,6 @@ T = TypeVar("T")
matchers: Dict[int, List[Type["Matcher"]]] = defaultdict(list)
"""
:类型: ``Dict[int, List[Type[Matcher]]]``
:说明: 用于存储当前所有的事件响应器
"""
current_bot: ContextVar[Bot] = ContextVar("current_bot")
@ -106,80 +105,65 @@ class Matcher(metaclass=MatcherMeta):
plugin: Optional["Plugin"] = None
"""
:类型: ``Optional[Plugin]``
:说明: 事件响应器所在插件
"""
module: Optional[ModuleType] = None
"""
:类型: ``Optional[ModuleType]``
:说明: 事件响应器所在插件模块
"""
plugin_name: Optional[str] = None
"""
:类型: ``Optional[str]``
:说明: 事件响应器所在插件名
"""
module_name: Optional[str] = None
"""
:类型: ``Optional[str]``
:说明: 事件响应器所在点分割插件模块路径
"""
type: str = ""
"""
:类型: ``str``
:说明: 事件响应器类型
"""
rule: Rule = Rule()
"""
:类型: ``Rule``
:说明: 事件响应器匹配规则
"""
permission: Permission = Permission()
"""
:类型: ``Permission``
:说明: 事件响应器触发权限
"""
handlers: List[Dependent[Any]] = []
"""
:类型: ``List[Handler]``
:说明: 事件响应器拥有的事件处理函数列表
"""
priority: int = 1
"""
:类型: ``int``
:说明: 事件响应器优先级
"""
block: bool = False
"""
:类型: ``bool``
:说明: 事件响应器是否阻止事件传播
"""
temp: bool = False
"""
:类型: ``bool``
:说明: 事件响应器是否为临时
"""
expire_time: Optional[datetime] = None
"""
:类型: ``Optional[datetime]``
:说明: 事件响应器过期时间点
"""
_default_state: T_State = {}
"""
:类型: ``T_State``
:说明: 事件响应器默认状态
"""
_default_type_updater: Optional[Dependent[str]] = None
"""
:类型: ``Optional[Dependent]``
:说明: 事件响应器类型更新函数
"""
_default_permission_updater: Optional[Dependent[Permission]] = None
"""
:类型: ``Optional[Dependent]``
:说明: 事件响应器权限更新函数
"""

View File

@ -77,10 +77,6 @@ class Permission:
:说明:
存储 ``PermissionChecker``
:类型:
* ``Set[Dependent[bool]]``
"""
async def __call__(

View File

@ -485,14 +485,12 @@ class CommandGroup:
"""
self.basecmd: Tuple[str, ...] = (cmd,) if isinstance(cmd, str) else cmd
"""
- **类型**: ``Tuple[str, ...]``
- **说明**: 命令前缀
"""
if "aliases" in kwargs:
del kwargs["aliases"]
self.base_kwargs: Dict[str, Any] = kwargs
"""
- **类型**: ``Dict[str, Any]``
- **说明**: 其他传递给 ``on_command`` 的参数默认值
"""
@ -554,12 +552,10 @@ class MatcherGroup:
"""
self.matchers: List[Type[Matcher]] = []
"""
:类型: ``List[Type[Matcher]]``
:说明: 组内事件响应器列表
"""
self.base_kwargs: Dict[str, Any] = kwargs
"""
- **类型**: ``Dict[str, Any]``
- **说明**: 其他传递给 ``on`` 的参数默认值
"""

View File

@ -10,7 +10,6 @@ if TYPE_CHECKING:
plugins: Dict[str, "Plugin"] = {}
"""
:类型: ``Dict[str, Plugin]``
:说明: 已加载的插件
"""
@ -21,42 +20,34 @@ class Plugin(object):
name: str
"""
- **类型**: ``str``
- **说明**: 插件名称使用 文件/文件夹 名称作为插件名
"""
module: ModuleType
"""
- **类型**: ``ModuleType``
- **说明**: 插件模块对象
"""
module_name: str
"""
- **类型**: ``str``
- **说明**: 点分割模块路径
"""
manager: "PluginManager"
"""
- **类型**: ``PluginManager``
- **说明**: 导入该插件的插件管理器
"""
export: Export = field(default_factory=Export)
"""
- **类型**: ``Export``
- **说明**: 插件内定义的导出内容
"""
matcher: Set[Type[Matcher]] = field(default_factory=set)
"""
- **类型**: ``Set[Type[Matcher]]``
- **说明**: 插件内定义的 ``Matcher``
"""
parent_plugin: Optional["Plugin"] = None
"""
- **类型**: ``Optional[Plugin]``
- **说明**: 父插件
"""
sub_plugins: Set["Plugin"] = field(default_factory=set)
"""
- **类型**: ``Set[Plugin]``
- **说明**: 子插件集合
"""

View File

@ -106,10 +106,6 @@ class Rule:
:说明:
存储 ``RuleChecker``
:类型:
* ``Set[Dependent[bool]]``
"""
async def __call__(

View File

@ -47,8 +47,6 @@ def overrides(InterfaceClass: object):
T_State = Dict[Any, Any]
"""
:类型: ``Dict[Any, Any]``
:说明:
事件处理状态 State 类型
@ -56,24 +54,18 @@ T_State = Dict[Any, Any]
T_BotConnectionHook = Callable[["Bot"], Awaitable[None]]
"""
:类型: ``Callable[[Bot], Awaitable[None]]``
:说明:
Bot 连接建立时执行的函数
"""
T_BotDisconnectionHook = Callable[["Bot"], Awaitable[None]]
"""
:类型: ``Callable[[Bot], Awaitable[None]]``
:说明:
Bot 连接断开时执行的函数
"""
T_CallingAPIHook = Callable[["Bot", str, Dict[str, Any]], Awaitable[None]]
"""
:类型: ``Callable[[Bot, str, Dict[str, Any]], Awaitable[None]]``
:说明:
``bot.call_api`` 时执行的函数
@ -82,8 +74,6 @@ T_CalledAPIHook = Callable[
["Bot", Optional[Exception], str, Dict[str, Any], Any], Awaitable[None]
]
"""
:类型: ``Callable[[Bot, Optional[Exception], str, Dict[str, Any], Any], Awaitable[None]]``
:说明:
``bot.call_api`` 后执行的函数参数分别为 bot, exception, api, data, result
@ -91,8 +81,6 @@ T_CalledAPIHook = Callable[
T_EventPreProcessor = Callable[..., Union[None, Awaitable[None]]]
"""
:类型: ``Callable[..., Union[None, Awaitable[None]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -107,8 +95,6 @@ T_EventPreProcessor = Callable[..., Union[None, Awaitable[None]]]
"""
T_EventPostProcessor = Callable[..., Union[None, Awaitable[None]]]
"""
:类型: ``Callable[..., Union[None, Awaitable[None]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -123,8 +109,6 @@ T_EventPostProcessor = Callable[..., Union[None, Awaitable[None]]]
"""
T_RunPreProcessor = Callable[..., Union[None, Awaitable[None]]]
"""
:类型: ``Callable[..., Union[None, Awaitable[None]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -140,8 +124,6 @@ T_RunPreProcessor = Callable[..., Union[None, Awaitable[None]]]
"""
T_RunPostProcessor = Callable[..., Union[None, Awaitable[None]]]
"""
:类型: ``Callable[..., Union[None, Awaitable[None]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -159,8 +141,6 @@ T_RunPostProcessor = Callable[..., Union[None, Awaitable[None]]]
T_RuleChecker = Callable[..., Union[bool, Awaitable[bool]]]
"""
:类型: ``Callable[..., Union[bool, Awaitable[bool]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -175,8 +155,6 @@ T_RuleChecker = Callable[..., Union[bool, Awaitable[bool]]]
"""
T_PermissionChecker = Callable[..., Union[bool, Awaitable[bool]]]
"""
:类型: ``Callable[..., Union[bool, Awaitable[bool]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -191,16 +169,12 @@ T_PermissionChecker = Callable[..., Union[bool, Awaitable[bool]]]
T_Handler = Callable[..., Any]
"""
:类型: ``Callable[..., Any]``
:说明:
Handler 处理函数
"""
T_TypeUpdater = Callable[..., Union[str, Awaitable[str]]]
"""
:类型: ``Callable[..., Union[None, Awaitable[None]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -216,8 +190,6 @@ T_TypeUpdater = Callable[..., Union[str, Awaitable[str]]]
"""
T_PermissionUpdater = Callable[..., Union["Permission", Awaitable["Permission"]]]
"""
:类型: ``Callable[..., Union[Permission, Awaitable[Permission]]]``
:依赖参数:
* ``DependParam``: 子依赖参数
@ -233,7 +205,6 @@ T_PermissionUpdater = Callable[..., Union["Permission", Awaitable["Permission"]]
"""
T_DependencyCache = Dict[Callable[..., Any], "Task[Any]"]
"""
:类型: ``Dict[Callable[..., Any], Task[Any]]``
:说明:
依赖缓存, 用于存储依赖函数的返回值
"""