mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 02:50:48 +00:00
♿ allow extra param with default value
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user