🐛 fix union validation error (#1001)

This commit is contained in:
Ju4tCode
2022-05-22 19:42:30 +08:00
committed by GitHub
parent fe43cc92a5
commit 6feed0610b
7 changed files with 144 additions and 24 deletions

View File

@ -1,3 +1,5 @@
from typing import Union
from nonebot.adapters import Bot
@ -5,9 +7,29 @@ async def get_bot(b: Bot) -> Bot:
return b
class SubBot(Bot):
async def legacy_bot(bot):
return bot
async def not_legacy_bot(bot: int):
...
async def sub_bot(b: SubBot) -> SubBot:
class FooBot(Bot):
...
async def sub_bot(b: FooBot) -> FooBot:
return b
class BarBot(Bot):
...
async def union_bot(b: Union[FooBot, BarBot]) -> Union[FooBot, BarBot]:
return b
async def not_bot(b: Union[int, Bot]):
...