Skip to content

Commit

Permalink
🎨 格式化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
XYCode-Kerman committed Jul 17, 2024
1 parent 611aa19 commit 78cfdeb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mirai_onebot/api/api_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class ApiProvider(abc.ABC):
"""用于提供Api调用。"""

@abc.abstractmethod
async def _call_api(self, action: str, params: dict, echo: str = secrets.token_hex(8)) -> Union[Dict[str, Any], None]:
async def _call_api(
self, action: str, params: dict, echo: str = secrets.token_hex(8)
) -> Union[Dict[str, Any], None]:
"""内部接口。直接调用API
Args:
Expand All @@ -18,11 +20,15 @@ async def _call_api(self, action: str, params: dict, echo: str = secrets.token_h
echo (str): 回显数值,用于标识唯一请求
"""

async def call(self, request: Request, response_type: Type[Response]):
async def call(self, request: Request, response_type: Type[Response]) -> Response:
"""调用API
Args:
api (Request): API接口
"""
resp = await self._call_api(request.action, request.params.model_dump(mode='json'), request.echo if request.echo is not None else secrets.token_hex(8))
resp = await self._call_api(
request.action,
request.params.model_dump(mode="json"),
request.echo if request.echo is not None else secrets.token_hex(8),
)
return response_type.model_validate(resp)

0 comments on commit 78cfdeb

Please sign in to comment.