💄 Format with black 24.x.x

This commit is contained in:
xtaodada 2024-03-16 18:44:26 +08:00
parent 968b3fd52d
commit 3057fba7a6
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
11 changed files with 31 additions and 6 deletions

View File

@ -1,4 +1,5 @@
"""BOT""" """BOT"""
import asyncio import asyncio
import signal import signal
from functools import wraps from functools import wraps

View File

@ -1,4 +1,5 @@
"""上下文管理""" """上下文管理"""
from contextlib import contextmanager from contextlib import contextmanager
from contextvars import ContextVar from contextvars import ContextVar
from typing import TYPE_CHECKING from typing import TYPE_CHECKING

View File

@ -1,4 +1,5 @@
"""参数分发器""" """参数分发器"""
import asyncio import asyncio
import inspect import inspect
from abc import ABC, abstractmethod from abc import ABC, abstractmethod

View File

@ -1,4 +1,5 @@
"""执行器""" """执行器"""
import inspect import inspect
from functools import cached_property from functools import cached_property
from multiprocessing import RLock as Lock from multiprocessing import RLock as Lock

View File

@ -44,7 +44,9 @@ class AioBrowser(BaseService.Dependence):
"[blue bold]playwright install chromium[/]", "[blue bold]playwright install chromium[/]",
extra={"markup": True}, extra={"markup": True},
) )
raise RuntimeError("检查到 playwright 刚刚安装或者未升级\n请运行以下命令下载新浏览器\nplaywright install chromium") raise RuntimeError(
"检查到 playwright 刚刚安装或者未升级\n请运行以下命令下载新浏览器\nplaywright install chromium"
)
raise err raise err
return self._browser return self._browser

View File

@ -1,4 +1,5 @@
"""此模块包含核心模块的错误的基类""" """此模块包含核心模块的错误的基类"""
from typing import Union from typing import Union

View File

@ -37,7 +37,11 @@ def _load_module(path: Path) -> None:
import_module(pkg) import_module(pkg)
except Exception as e: except Exception as e:
logger.exception( logger.exception(
'在导入 "%s" 的过程中遇到了错误 [red bold]%s[/]', pkg, type(e).__name__, exc_info=e, extra={"markup": True} '在导入 "%s" 的过程中遇到了错误 [red bold]%s[/]',
pkg,
type(e).__name__,
exc_info=e,
extra={"markup": True},
) )
raise SystemExit from e raise SystemExit from e
@ -205,7 +209,9 @@ class ServiceManager(Manager[BaseServiceType]):
): ):
_load_module(path) _load_module(path)
for service in filter(lambda x: not x.is_component and not x.is_dependence, get_all_services()): # 遍历所有服务类 for service in filter(
lambda x: not x.is_component and not x.is_dependence, get_all_services()
): # 遍历所有服务类
instance = await self._initialize_service(service) instance = await self._initialize_service(service)
self._lib[service] = instance self._lib[service] = instance

View File

@ -1,4 +1,5 @@
"""重写 telegram.request.HTTPXRequest 使其使用 ujson 库进行 json 序列化""" """重写 telegram.request.HTTPXRequest 使其使用 ujson 库进行 json 序列化"""
from typing import Any, AsyncIterable, Optional from typing import Any, AsyncIterable, Optional
import httpcore import httpcore

View File

@ -1,4 +1,5 @@
"""插件""" """插件"""
import datetime import datetime
import re import re
from dataclasses import dataclass, field from dataclasses import dataclass, field

View File

@ -1,4 +1,5 @@
"""插件""" """插件"""
import asyncio import asyncio
from abc import ABC from abc import ABC
from dataclasses import asdict from dataclasses import asdict
@ -292,7 +293,9 @@ class _Conversation(_Plugin, ConversationFuncs, ABC):
temp_dict = {"entry_points": entry_points, "states": states, "fallbacks": fallbacks} temp_dict = {"entry_points": entry_points, "states": states, "fallbacks": fallbacks}
reason = map(lambda x: f"'{x[0]}'", filter(lambda x: not x[1], temp_dict.items())) reason = map(lambda x: f"'{x[0]}'", filter(lambda x: not x[1], temp_dict.items()))
logger.warning( logger.warning(
"'%s' 因缺少 '%s' 而生成无法生成 ConversationHandler", self.__class__.__name__, ", ".join(reason) "'%s' 因缺少 '%s' 而生成无法生成 ConversationHandler",
self.__class__.__name__,
", ".join(reason),
) )
return self._handlers return self._handlers

View File

@ -107,7 +107,12 @@ class PublicCookiesService:
continue continue
try: try:
await self.check_public_cookie(region, cookies, public_id) await self.check_public_cookie(region, cookies, public_id)
logger.info("用户 user_id[%s] 请求用户 user_id[%s] 的公共Cookies 该Cookies使用次数为%s", user_id, public_id, count) logger.info(
"用户 user_id[%s] 请求用户 user_id[%s] 的公共Cookies 该Cookies使用次数为%s",
user_id,
public_id,
count,
)
return cookies return cookies
except NeedContinue: except NeedContinue:
continue continue
@ -118,7 +123,9 @@ class PublicCookiesService:
cookies.status = status cookies.status = status
await self._repository.update(cookies) await self._repository.update(cookies)
await self._cache.delete_public_cookies(cookies.user_id, cookies.region) await self._cache.delete_public_cookies(cookies.user_id, cookies.region)
logger.info("用户 user_id[%s] 反馈用户 user_id[%s] 的Cookies状态为 %s", user_id, cookies.user_id, status.name) logger.info(
"用户 user_id[%s] 反馈用户 user_id[%s] 的Cookies状态为 %s", user_id, cookies.user_id, status.name
)
else: else:
logger.info("用户 user_id[%s] 撤销一次公共Cookies计数", user_id) logger.info("用户 user_id[%s] 撤销一次公共Cookies计数", user_id)