allow extra param with default value

This commit is contained in:
yanyongyu
2021-11-22 11:38:42 +08:00
parent 23c237cb2a
commit 3120abacb3
7 changed files with 45 additions and 26 deletions

View File

@ -1,6 +1,8 @@
import inspect
from typing import Any, Dict, Optional
from pydantic.fields import Undefined
from nonebot.typing import T_State
from nonebot.dependencies import Param
from nonebot.adapters import Bot, Event
@ -69,4 +71,14 @@ class ExceptionParam(Param):
return exception
class DefaultParam(Param):
@classmethod
def _check(cls, name: str, param: inspect.Parameter) -> bool:
return param.default != param.empty
def _solve(self, **kwargs: Any) -> Any:
return Undefined
from nonebot.matcher import Matcher