mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 00:55:07 +08:00
✨ Feature: 添加遗漏的类型标注 (#2856)
This commit is contained in:
parent
976c1cd8e0
commit
c97a780645
@ -76,7 +76,7 @@ T = TypeVar("T")
|
||||
current_bot: ContextVar[Bot] = ContextVar("current_bot")
|
||||
current_event: ContextVar[Event] = ContextVar("current_event")
|
||||
current_matcher: ContextVar["Matcher"] = ContextVar("current_matcher")
|
||||
current_handler: ContextVar[Dependent] = ContextVar("current_handler")
|
||||
current_handler: ContextVar[Dependent[Any]] = ContextVar("current_handler")
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -102,7 +102,7 @@ class DependParam(Param):
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, *args, dependent: Dependent, use_cache: bool, **kwargs: Any
|
||||
self, *args, dependent: Dependent[Any], use_cache: bool, **kwargs: Any
|
||||
) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
self.dependent = dependent
|
||||
@ -114,7 +114,7 @@ class DependParam(Param):
|
||||
@classmethod
|
||||
def _from_field(
|
||||
cls,
|
||||
sub_dependent: Dependent,
|
||||
sub_dependent: Dependent[Any],
|
||||
use_cache: bool,
|
||||
validate: Union[bool, PydanticFieldInfo],
|
||||
) -> Self:
|
||||
@ -190,7 +190,7 @@ class DependParam(Param):
|
||||
use_cache: bool = self.use_cache
|
||||
dependency_cache = {} if dependency_cache is None else dependency_cache
|
||||
|
||||
sub_dependent: Dependent = self.dependent
|
||||
sub_dependent = self.dependent
|
||||
call = cast(Callable[..., Any], sub_dependent.call)
|
||||
|
||||
# solve sub dependency with current cache
|
||||
|
@ -114,7 +114,7 @@ def on(
|
||||
rule: Optional[Union[Rule, T_RuleChecker]] = None,
|
||||
permission: Optional[Union[Permission, T_PermissionChecker]] = None,
|
||||
*,
|
||||
handlers: Optional[list[Union[T_Handler, Dependent]]] = None,
|
||||
handlers: Optional[list[Union[T_Handler, Dependent[Any]]]] = None,
|
||||
temp: bool = False,
|
||||
expire_time: Optional[Union[datetime, timedelta]] = None,
|
||||
priority: int = 1,
|
||||
|
@ -21,7 +21,7 @@ def on(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
*,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -32,7 +32,7 @@ def on_metaevent(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
*,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -43,7 +43,7 @@ def on_message(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
*,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -54,7 +54,7 @@ def on_notice(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
*,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -65,7 +65,7 @@ def on_request(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
*,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -78,7 +78,7 @@ def on_startswith(
|
||||
ignorecase: bool = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -91,7 +91,7 @@ def on_endswith(
|
||||
ignorecase: bool = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -104,7 +104,7 @@ def on_fullmatch(
|
||||
ignorecase: bool = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -116,7 +116,7 @@ def on_keyword(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -130,7 +130,7 @@ def on_command(
|
||||
force_whitespace: str | bool | None = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -144,7 +144,7 @@ def on_shell_command(
|
||||
parser: ArgumentParser | None = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -157,7 +157,7 @@ def on_regex(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -169,7 +169,7 @@ def on_type(
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
*,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -194,7 +194,7 @@ class CommandGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -209,7 +209,7 @@ class CommandGroup(_Group):
|
||||
aliases: set[str | tuple[str, ...]] | None = ...,
|
||||
force_whitespace: str | bool | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -224,7 +224,7 @@ class CommandGroup(_Group):
|
||||
aliases: set[str | tuple[str, ...]] | None = ...,
|
||||
parser: ArgumentParser | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -239,7 +239,7 @@ class MatcherGroup(_Group):
|
||||
type: str = ...,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -252,7 +252,7 @@ class MatcherGroup(_Group):
|
||||
type: str = ...,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -264,7 +264,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -276,7 +276,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -288,7 +288,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -300,7 +300,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -314,7 +314,7 @@ class MatcherGroup(_Group):
|
||||
ignorecase: bool = ...,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -328,7 +328,7 @@ class MatcherGroup(_Group):
|
||||
ignorecase: bool = ...,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -342,7 +342,7 @@ class MatcherGroup(_Group):
|
||||
ignorecase: bool = ...,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -355,7 +355,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -370,7 +370,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -385,7 +385,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -399,7 +399,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
@ -412,7 +412,7 @@ class MatcherGroup(_Group):
|
||||
*,
|
||||
rule: Rule | T_RuleChecker | None = ...,
|
||||
permission: Permission | T_PermissionChecker | None = ...,
|
||||
handlers: list[T_Handler | Dependent] | None = ...,
|
||||
handlers: list[T_Handler | Dependent[Any]] | None = ...,
|
||||
temp: bool = ...,
|
||||
expire_time: datetime | timedelta | None = ...,
|
||||
priority: int = ...,
|
||||
|
@ -574,7 +574,7 @@ async def test_default(app: App):
|
||||
async def test_priority():
|
||||
from plugins.param.priority import complex_priority
|
||||
|
||||
dependent = Dependent.parse(
|
||||
dependent = Dependent[None].parse(
|
||||
call=complex_priority,
|
||||
allow_types=[
|
||||
DependParam,
|
||||
|
Loading…
Reference in New Issue
Block a user