Feature: 依赖注入支持 Generic TypeVar 和 Matcher 重载 (#2089)

This commit is contained in:
Ju4tCode
2023-06-11 15:33:33 +08:00
committed by GitHub
parent 6181c1760f
commit f6b0809e5f
9 changed files with 198 additions and 10 deletions

View File

@ -1,4 +1,4 @@
from typing import Union
from typing import Union, TypeVar
from nonebot.adapters import Bot
@ -31,5 +31,19 @@ async def union_bot(b: Union[FooBot, BarBot]) -> Union[FooBot, BarBot]:
return b
B = TypeVar("B", bound=Bot)
async def generic_bot(b: B) -> B:
return b
CB = TypeVar("CB", Bot, None)
async def generic_bot_none(b: CB) -> CB:
return b
async def not_bot(b: Union[int, Bot]):
...