mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-06 03:56:45 +00:00
♻️ allow dynamic param types
This commit is contained in:
@ -55,6 +55,16 @@ class Bot(abc.ABC):
|
||||
def __getattr__(self, name: str) -> _ApiCall:
|
||||
return partial(self.call_api, name)
|
||||
|
||||
@classmethod
|
||||
def __get_validators__(cls):
|
||||
yield cls.validate
|
||||
|
||||
@classmethod
|
||||
def validate(cls, v):
|
||||
if not isinstance(v, cls):
|
||||
raise TypeError(f"{v} is not an instance of {cls}")
|
||||
return v
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def type(self) -> str:
|
||||
|
Reference in New Issue
Block a user