♻️ allow dynamic param types

This commit is contained in:
yanyongyu
2021-11-15 21:44:24 +08:00
parent cafe5c9af0
commit d1c6eeb6c2
7 changed files with 260 additions and 157 deletions

View File

@ -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: