♻️ rewrite dependency injection system

This commit is contained in:
yanyongyu
2021-12-12 18:19:08 +08:00
parent 6b5a5e53eb
commit 66ba25494a
17 changed files with 728 additions and 733 deletions

23
tests/plugins/depends.py Normal file
View File

@ -0,0 +1,23 @@
from nonebot import on_message
from nonebot.adapters import Event
from nonebot.params import Depends
test = on_message()
test2 = on_message()
runned = False
def dependency(event: Event):
# test cache
global runned
assert not runned
runned = True
return event
@test.handle()
@test2.handle()
async def handle(x: Event = Depends(dependency)):
# test dependency
return x