nonebot2/tests/plugins/param/param_bot.py

50 lines
663 B
Python
Raw Normal View History

from typing import Union, TypeVar
2021-12-20 00:28:02 +08:00
from nonebot.adapters import Bot
async def get_bot(b: Bot) -> Bot:
return b
async def postpone_bot(b: "Bot") -> Bot:
return b
async def legacy_bot(bot):
return bot
async def not_legacy_bot(bot: int): ...
class FooBot(Bot): ...
async def sub_bot(b: FooBot) -> FooBot:
2021-12-20 00:28:02 +08:00
return b
class BarBot(Bot): ...
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]): ...