Skip to content

Commit

Permalink
✨ Feature: 添加遗漏的类型标注 (#2856)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Aug 6, 2024
1 parent 976c1cd commit c97a780
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion nonebot/internal/matcher/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
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
Expand Down
6 changes: 3 additions & 3 deletions nonebot/internal/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -114,7 +114,7 @@ def __repr__(self) -> str:
@classmethod
def _from_field(
cls,
sub_dependent: Dependent,
sub_dependent: Dependent[Any],
use_cache: bool,
validate: Union[bool, PydanticFieldInfo],
) -> Self:
Expand Down Expand Up @@ -190,7 +190,7 @@ async def _solve(
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
Expand Down
2 changes: 1 addition & 1 deletion nonebot/plugin/on.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
60 changes: 30 additions & 30 deletions nonebot/plugin/on.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c97a780

Please sign in to comment.