From 027ee55903b46f647efbb39ffda101959b88ed2a Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Sun, 12 Sep 2021 13:28:22 +0800 Subject: [PATCH] :art: update formatter config --- pyproject.toml | 4 ++- src/libs/github/__init__.py | 28 ++++++++++++++----- src/libs/github/models/__init__.py | 18 ++++++++++-- src/libs/github/models/issue.py | 8 ++++-- src/libs/github/models/repository.py | 8 ++++-- src/libs/html2img/api.py | 4 ++- src/libs/html2img/config.py | 8 ++++-- src/libs/html2img/imgkit.py | 13 +++++++-- src/libs/md2img/__init__.py | 8 ++++-- src/plugins/github/__init__.py | 4 ++- src/plugins/github/config.py | 4 ++- src/plugins/github/libs/auth.py | 4 ++- src/plugins/github/libs/hook.py | 4 ++- src/plugins/github/libs/issue/__init__.py | 4 ++- src/plugins/github/libs/redis/__init__.py | 14 ++++++++-- src/plugins/github/libs/redis/state.py | 4 ++- src/plugins/github/libs/redis/subscribe.py | 16 ++++++++--- src/plugins/github/libs/repo.py | 4 ++- .../github/plugins/github_bind/__init__.py | 11 ++++++-- .../github/plugins/github_help/__init__.py | 5 +++- .../github/plugins/github_issue/__init__.py | 15 ++++++++-- .../github/plugins/github_reply/content.py | 12 ++++++-- .../github/plugins/github_reply/diff.py | 12 ++++++-- .../github/plugins/github_reply/link.py | 4 ++- .../github/plugins/github_repo/__init__.py | 7 ++++- .../plugins/github_subscribe/__init__.py | 4 ++- src/plugins/nonebot_plugin_sentry/config.py | 4 ++- src/plugins/nonebot_plugin_status/__init__.py | 6 ++-- .../nonebot_plugin_status/data_source.py | 4 ++- src/plugins/redis_provider/__init__.py | 4 ++- 30 files changed, 189 insertions(+), 56 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c9e3b32..dec9f7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,13 +33,15 @@ nb-cli = {version = "^0.5.0", extras = ["deploy"]} # default = true [tool.black] -line-length = 90 +line-length = 80 extend-exclude = ''' ''' [tool.isort] profile = "black" +line_length = 80 length_sort = true +skip_gitignore = true force_sort_within_sections = true extra_standard_library = "typing_extensions" diff --git a/src/libs/github/__init__.py b/src/libs/github/__init__.py index 7fbe9a4..3cfcd7c 100644 --- a/src/libs/github/__init__.py +++ b/src/libs/github/__init__.py @@ -53,14 +53,20 @@ class Github: return await self._requester.close() @overload - async def get_repo(self, full_name: str, lazy: Literal[True]) -> LazyRepository: + async def get_repo( + self, full_name: str, lazy: Literal[True] + ) -> LazyRepository: ... @overload - async def get_repo(self, full_name: str, lazy: Literal[False]) -> Repository: + async def get_repo( + self, full_name: str, lazy: Literal[False] + ) -> Repository: ... - async def get_repo(self, full_name: str, lazy: bool = False) -> LazyRepository: + async def get_repo( + self, full_name: str, lazy: bool = False + ) -> LazyRepository: """ GET /repos/:owner/:repo @@ -68,11 +74,17 @@ class Github: """ url = f"/repos/{full_name}" if lazy: - return LazyRepository(full_name=full_name, requester=self._requester) + return LazyRepository( + full_name=full_name, requester=self._requester + ) response = await self._requester.request_json("GET", url) - return Repository.parse_obj({"requester": self._requester, **response.json()}) + return Repository.parse_obj( + {"requester": self._requester, **response.json()} + ) - async def render_markdown(self, text: str, context: Optional[Repository] = None): + async def render_markdown( + self, text: str, context: Optional[Repository] = None + ): """ POST /markdown @@ -83,7 +95,9 @@ class Github: # if context: # data["mode"] = "gfm" # data["context"] = context._identity - response = await self._requester.request_json("POST", "/markdown", json=data) + response = await self._requester.request_json( + "POST", "/markdown", json=data + ) return response.text # def get_repos( diff --git a/src/libs/github/models/__init__.py b/src/libs/github/models/__init__.py index d7a21bb..f1f0034 100644 --- a/src/libs/github/models/__init__.py +++ b/src/libs/github/models/__init__.py @@ -58,7 +58,12 @@ C = TypeVar("C", bound=BaseModel) class PaginatedList(AsyncIterator, Generic[C]): def __init__( - self, cls: Type[C], requester: Requester, *args, per_page: int = 30, **kwargs + self, + cls: Type[C], + requester: Requester, + *args, + per_page: int = 30, + **kwargs ): self.cls = cls self.requester = requester @@ -80,7 +85,11 @@ class PaginatedList(AsyncIterator, Generic[C]): def __aiter__(self) -> "PaginatedList[C]": return PaginatedList( - self.cls, self.requester, *self.args, per_page=self.per_page, **self.kwargs + self.cls, + self.requester, + *self.args, + per_page=self.per_page, + **self.kwargs ) async def _get_next_page(self) -> List[C]: @@ -91,7 +100,10 @@ class PaginatedList(AsyncIterator, Generic[C]): response = await self.requester.request_json(*self.args, **self.kwargs) content = response.json() self._contents.extend( - [parse_obj_as(self.cls, {"requester": self.requester, **x}) for x in content] + [ + parse_obj_as(self.cls, {"requester": self.requester, **x}) + for x in content + ] ) return content diff --git a/src/libs/github/models/issue.py b/src/libs/github/models/issue.py index 4043b98..3a2d86e 100644 --- a/src/libs/github/models/issue.py +++ b/src/libs/github/models/issue.py @@ -159,7 +159,9 @@ class Issue(BaseModel): response = await self.requester.request( "GET", self.pull_request.url, headers=headers ) - return PullRequest.parse_obj({"requester": self.requester, **response.json()}) + return PullRequest.parse_obj( + {"requester": self.requester, **response.json()} + ) async def get_diff(self) -> str: """ @@ -168,5 +170,7 @@ class Issue(BaseModel): if not self.pull_request: raise RuntimeError(f"Issue {self.number} is not a pull request") - response = await self.requester.request("GET", self.pull_request.diff_url) + response = await self.requester.request( + "GET", self.pull_request.diff_url + ) return response.text diff --git a/src/libs/github/models/repository.py b/src/libs/github/models/repository.py index 78c6c8e..f212058 100644 --- a/src/libs/github/models/repository.py +++ b/src/libs/github/models/repository.py @@ -30,7 +30,9 @@ class LazyRepository(BaseModel): https://docs.github.com/en/rest/reference/issues#get-an-issue """ - headers = {"Accept": "application/vnd.github.mockingbird-preview.full+json"} + headers = { + "Accept": "application/vnd.github.mockingbird-preview.full+json" + } response = await self.requester.request( "GET", f"/repos/{self.full_name}/issues/{number}", headers=headers ) @@ -107,7 +109,9 @@ class LazyRepository(BaseModel): """ data = {} data["config"] = config.dict(exclude_unset=True) - data["config"]["insecure_ssl"] = "1" if data["config"]["insecure_ssl"] else "0" + data["config"]["insecure_ssl"] = ( + "1" if data["config"]["insecure_ssl"] else "0" + ) if events is not None: data["events"] = events if active is not None: diff --git a/src/libs/html2img/api.py b/src/libs/html2img/api.py index 8f24568..68f09ce 100644 --- a/src/libs/html2img/api.py +++ b/src/libs/html2img/api.py @@ -216,4 +216,6 @@ async def config( :param meta_tag_prefix: the prefix for ``pdfkit`` specific meta tags """ - return await Config(wkhtmltoimage=wkhtmltoimage, meta_tag_prefix=meta_tag_prefix) + return await Config( + wkhtmltoimage=wkhtmltoimage, meta_tag_prefix=meta_tag_prefix + ) diff --git a/src/libs/html2img/config.py b/src/libs/html2img/config.py index 8e103bc..b25ba63 100644 --- a/src/libs/html2img/config.py +++ b/src/libs/html2img/config.py @@ -18,7 +18,9 @@ from typing import Union, Optional class Config(object): def __init__( - self, wkhtmltoimage: Optional[str] = None, meta_tag_prefix: str = "imgkit-" + self, + wkhtmltoimage: Optional[str] = None, + meta_tag_prefix: str = "imgkit-", ): self.meta_tag_prefix = meta_tag_prefix self._wkhtmltoimage = wkhtmltoimage @@ -84,7 +86,9 @@ class Config(object): @property def xvfb(self) -> Union[str, bytes]: if not self._xvfb: - raise RuntimeError(f"xvfb not installed or Config {self} is never awaited!") + raise RuntimeError( + f"xvfb not installed or Config {self} is never awaited!" + ) return self._xvfb @xvfb.setter diff --git a/src/libs/html2img/imgkit.py b/src/libs/html2img/imgkit.py index 0ec8e99..e743f01 100644 --- a/src/libs/html2img/imgkit.py +++ b/src/libs/html2img/imgkit.py @@ -96,7 +96,9 @@ class IMGKit(object): def xvfb(self): return self.config.xvfb - def _gegetate_args(self, options: OPTION_TYPE) -> Generator[str, None, None]: + def _gegetate_args( + self, options: OPTION_TYPE + ) -> Generator[str, None, None]: """ Generator of args parts based on options specification. """ @@ -155,7 +157,9 @@ class IMGKit(object): if "" in source: self.source = StringSource( - inp.replace("", self._style_tag(css_data) + "") + inp.replace( + "", self._style_tag(css_data) + "" + ) ) else: self.source = StringSource(self._style_tag(css_data) + inp) @@ -252,7 +256,10 @@ class IMGKit(object): args = self.command(output_path) proc = await asyncio.create_subprocess_exec( - *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE + *args, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) # If the source is a string then we will pipe it into wkhtmltoimage. diff --git a/src/libs/md2img/__init__.py b/src/libs/md2img/__init__.py index 9d30653..a5a36c1 100644 --- a/src/libs/md2img/__init__.py +++ b/src/libs/md2img/__init__.py @@ -21,7 +21,9 @@ from src.libs import html2img async def from_string( string: str, - extensions: Optional[Sequence[Union[str, markdown.extensions.Extension]]] = None, + extensions: Optional[ + Sequence[Union[str, markdown.extensions.Extension]] + ] = None, extension_configs: Optional[Mapping[str, Mapping[str, Any]]] = None, output_format: Optional[Literal["xhtml", "html"]] = None, tab_length: Optional[int] = None, @@ -39,7 +41,9 @@ async def from_string( async def from_file( input: Optional[Union[str, BinaryIO]] = None, encoding: Optional[str] = None, - extensions: Optional[Sequence[Union[str, markdown.extensions.Extension]]] = None, + extensions: Optional[ + Sequence[Union[str, markdown.extensions.Extension]] + ] = None, extension_configs: Optional[Mapping[str, Mapping[str, Any]]] = None, output_format: Optional[Literal["xhtml", "html"]] = None, tab_length: Optional[int] = None, diff --git a/src/plugins/github/__init__.py b/src/plugins/github/__init__.py index 2cba97f..ebaac1c 100644 --- a/src/plugins/github/__init__.py +++ b/src/plugins/github/__init__.py @@ -26,6 +26,8 @@ _sub_plugins = set() # load all github plugin config from global config github_config = Config(**nonebot.get_driver().config.dict()) -_sub_plugins |= nonebot.load_plugins(str((Path(__file__).parent / "plugins").resolve())) +_sub_plugins |= nonebot.load_plugins( + str((Path(__file__).parent / "plugins").resolve()) +) from . import apis diff --git a/src/plugins/github/config.py b/src/plugins/github/config.py index d9b5472..3bf64da 100644 --- a/src/plugins/github/config.py +++ b/src/plugins/github/config.py @@ -42,7 +42,9 @@ class Config(BaseSettings): @validator("github_self_host") def validate_hook(cls, v): if not v: - logger.warning("`github_self_host` not provided! github webhook is disabled!") + logger.warning( + "`github_self_host` not provided! github webhook is disabled!" + ) return v class Config: diff --git a/src/plugins/github/libs/auth.py b/src/plugins/github/libs/auth.py index 8510bca..2f4941a 100644 --- a/src/plugins/github/libs/auth.py +++ b/src/plugins/github/libs/auth.py @@ -64,7 +64,9 @@ async def get_token_by_code(code: str) -> str: "code": code, } response = await client.post( - "https://github.com/login/oauth/access_token", json=data, headers=headers + "https://github.com/login/oauth/access_token", + json=data, + headers=headers, ) response.raise_for_status() return response.json()["access_token"] diff --git a/src/plugins/github/libs/hook.py b/src/plugins/github/libs/hook.py index aad3b98..9c6ca47 100644 --- a/src/plugins/github/libs/hook.py +++ b/src/plugins/github/libs/hook.py @@ -51,7 +51,9 @@ async def create_hook( ) -> Hook: async with Github(token) as g: repo = await g.get_repo(repo, True) if isinstance(repo, str) else repo - config = HookConfig.parse_obj(config) if isinstance(config, dict) else config + config = ( + HookConfig.parse_obj(config) if isinstance(config, dict) else config + ) return await repo.create_hook(config, events, active) diff --git a/src/plugins/github/libs/issue/__init__.py b/src/plugins/github/libs/issue/__init__.py index 2574fe7..967714e 100644 --- a/src/plugins/github/libs/issue/__init__.py +++ b/src/plugins/github/libs/issue/__init__.py @@ -48,7 +48,9 @@ async def _gen_image( html: str, width: int, height: int, wkhtmltoimage: bool = False ) -> Optional[bytes]: if not wkhtmltoimage: - async with get_new_page(viewport={"width": width, "height": height}) as page: + async with get_new_page( + viewport={"width": width, "height": height} + ) as page: await page.set_content(html) img = await page.screenshot(full_page=True) return img diff --git a/src/plugins/github/libs/redis/__init__.py b/src/plugins/github/libs/redis/__init__.py index db5099e..8d694ee 100644 --- a/src/plugins/github/libs/redis/__init__.py +++ b/src/plugins/github/libs/redis/__init__.py @@ -12,8 +12,18 @@ __author__ = "yanyongyu" from ... import redis from .state import get_state_bind_user, set_state_bind_user -from .hook import get_repo_hook, set_repo_hook, delete_repo_hook, exists_repo_hook -from .token import get_user_token, set_user_token, delete_user_token, exists_user_token +from .hook import ( + get_repo_hook, + set_repo_hook, + delete_repo_hook, + exists_repo_hook, +) +from .token import ( + get_user_token, + set_user_token, + delete_user_token, + exists_user_token, +) from .bind import ( get_group_bind_repo, set_group_bind_repo, diff --git a/src/plugins/github/libs/redis/state.py b/src/plugins/github/libs/redis/state.py index 2fbc7ca..d48a677 100644 --- a/src/plugins/github/libs/redis/state.py +++ b/src/plugins/github/libs/redis/state.py @@ -19,7 +19,9 @@ USER_STATE_FORMAT = "github_state_{state}" def set_state_bind_user(user_id: str, state: int) -> Optional[bool]: - return redis.set(USER_STATE_FORMAT.format(state=state), user_id, timedelta(minutes=5)) + return redis.set( + USER_STATE_FORMAT.format(state=state), user_id, timedelta(minutes=5) + ) def get_state_bind_user(state: int) -> Optional[str]: diff --git a/src/plugins/github/libs/redis/subscribe.py b/src/plugins/github/libs/redis/subscribe.py index d213c41..3362674 100644 --- a/src/plugins/github/libs/redis/subscribe.py +++ b/src/plugins/github/libs/redis/subscribe.py @@ -35,26 +35,34 @@ class SubscribeConfig: def set_subscribe(group_id: str, repo_name: str, **kwargs) -> Optional[bool]: return redis.set( - SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name), + SUBSCRIBE_GROUP_REPO_FORMAT.format( + group_id=group_id, repo_name=repo_name + ), json.dumps(asdict(SubscribeConfig(**kwargs))), ) def delete_subscribe(group_id: str, repo_name: str) -> int: return redis.delete( - SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name) + SUBSCRIBE_GROUP_REPO_FORMAT.format( + group_id=group_id, repo_name=repo_name + ) ) def exists_subscribe(group_id: str, repo_name: str) -> int: return redis.exists( - SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name) + SUBSCRIBE_GROUP_REPO_FORMAT.format( + group_id=group_id, repo_name=repo_name + ) ) def get_subscribe(group_id: str, repo_name: str) -> Optional[SubscribeConfig]: value = redis.get( - SUBSCRIBE_GROUP_REPO_FORMAT.format(group_id=group_id, repo_name=repo_name) + SUBSCRIBE_GROUP_REPO_FORMAT.format( + group_id=group_id, repo_name=repo_name + ) ) return value if value is None else SubscribeConfig(**json.loads(value)) diff --git a/src/plugins/github/libs/repo.py b/src/plugins/github/libs/repo.py index 3c63cce..3b6f6b1 100644 --- a/src/plugins/github/libs/repo.py +++ b/src/plugins/github/libs/repo.py @@ -18,7 +18,9 @@ from src.libs.github.models import Repository from .. import github_config as config -async def get_repo(owner: str, repo_name: str, token: Optional[str] = None) -> Repository: +async def get_repo( + owner: str, repo_name: str, token: Optional[str] = None +) -> Repository: if token: g = Github(token) elif config.github_client_id and config.github_client_secret: diff --git a/src/plugins/github/plugins/github_bind/__init__.py b/src/plugins/github/plugins/github_bind/__init__.py index 23f6b90..12b2783 100644 --- a/src/plugins/github/plugins/github_bind/__init__.py +++ b/src/plugins/github/plugins/github_bind/__init__.py @@ -16,7 +16,12 @@ from nonebot import on_command from nonebot.typing import T_State from nonebot.permission import SUPERUSER from httpx import HTTPStatusError, TimeoutException -from nonebot.adapters.cqhttp import GROUP_ADMIN, GROUP_OWNER, Bot, GroupMessageEvent +from nonebot.adapters.cqhttp import ( + GROUP_ADMIN, + GROUP_OWNER, + Bot, + GroupMessageEvent, +) from src.utils import only_group, allow_cancel @@ -35,7 +40,9 @@ try: except ImportError: get_user_token = None -REPO_REGEX: str = r"^(?P[a-zA-Z0-9][a-zA-Z0-9\-]*)/(?P[a-zA-Z0-9_\-\.]+)$" +REPO_REGEX: str = ( + r"^(?P[a-zA-Z0-9][a-zA-Z0-9\-]*)/(?P[a-zA-Z0-9_\-\.]+)$" +) bind = on_command( "bind", diff --git a/src/plugins/github/plugins/github_help/__init__.py b/src/plugins/github/plugins/github_help/__init__.py index 3a5aa8d..4c3e7ad 100644 --- a/src/plugins/github/plugins/github_help/__init__.py +++ b/src/plugins/github/plugins/github_help/__init__.py @@ -31,6 +31,9 @@ async def handle(bot: Bot): matchers = reduce(lambda x, y: x.union(y.matcher), _sub_plugins, set()) docs = "命令列表:\n\n" docs += "\n\n".join( - map(lambda x: inspect.cleandoc(x.__doc__), filter(lambda x: x.__doc__, matchers)) + map( + lambda x: inspect.cleandoc(x.__doc__), + filter(lambda x: x.__doc__, matchers), + ) ) await help.finish(docs) diff --git a/src/plugins/github/plugins/github_issue/__init__.py b/src/plugins/github/plugins/github_issue/__init__.py index 093d6a6..b15f99b 100644 --- a/src/plugins/github/plugins/github_issue/__init__.py +++ b/src/plugins/github/plugins/github_issue/__init__.py @@ -18,7 +18,12 @@ from nonebot import on_regex from nonebot.typing import T_State from playwright.async_api import Error from httpx import HTTPStatusError, TimeoutException -from nonebot.adapters.cqhttp import Bot, MessageEvent, MessageSegment, GroupMessageEvent +from nonebot.adapters.cqhttp import ( + Bot, + MessageEvent, + MessageSegment, + GroupMessageEvent, +) from src.utils import only_group @@ -91,7 +96,9 @@ async def handle(bot: Bot, event: MessageEvent, state: T_State): owner, repo, number, - MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"), + MessageSegment.image( + f"base64://{base64.b64encode(img).decode()}" + ), ) @@ -144,5 +151,7 @@ async def handle_short(bot: Bot, event: GroupMessageEvent, state: T_State): owner, repo, number, - MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"), + MessageSegment.image( + f"base64://{base64.b64encode(img).decode()}" + ), ) diff --git a/src/plugins/github/plugins/github_reply/content.py b/src/plugins/github/plugins/github_reply/content.py index 4794c5c..341e9ec 100644 --- a/src/plugins/github/plugins/github_reply/content.py +++ b/src/plugins/github/plugins/github_reply/content.py @@ -29,7 +29,9 @@ try: except ImportError: get_user_token = None -content = on_command("content", is_github_reply, priority=config.github_command_priority) +content = on_command( + "content", is_github_reply, priority=config.github_command_priority +) content.__doc__ = """ /content 回复机器人一条github信息,给出对应内容 @@ -57,7 +59,9 @@ async def handle_content(bot: Bot, event: MessageEvent, state: T_State): return try: - img = await issue_to_image(message_info.owner, message_info.repo, issue_) + img = await issue_to_image( + message_info.owner, message_info.repo, issue_ + ) except TimeoutException: await content.finish(f"获取issue数据超时!请尝试重试") except Error: @@ -69,5 +73,7 @@ async def handle_content(bot: Bot, event: MessageEvent, state: T_State): message_info.owner, message_info.repo, message_info.number, - MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"), + MessageSegment.image( + f"base64://{base64.b64encode(img).decode()}" + ), ) diff --git a/src/plugins/github/plugins/github_reply/diff.py b/src/plugins/github/plugins/github_reply/diff.py index 16e4e74..d2daf41 100644 --- a/src/plugins/github/plugins/github_reply/diff.py +++ b/src/plugins/github/plugins/github_reply/diff.py @@ -29,7 +29,9 @@ try: except ImportError: get_user_token = None -diff = on_command("diff", is_github_reply, priority=config.github_command_priority) +diff = on_command( + "diff", is_github_reply, priority=config.github_command_priority +) diff.__doc__ = """ /diff 回复机器人一条github pr信息,给出pr diff @@ -57,7 +59,9 @@ async def handle_diff(bot: Bot, event: MessageEvent, state: T_State): return try: - img = await issue_diff_to_image(message_info.owner, message_info.repo, issue_) + img = await issue_diff_to_image( + message_info.owner, message_info.repo, issue_ + ) except TimeoutException: await diff.finish(f"获取diff数据超时!请尝试重试") except Error: @@ -69,5 +73,7 @@ async def handle_diff(bot: Bot, event: MessageEvent, state: T_State): message_info.owner, message_info.repo, message_info.number, - MessageSegment.image(f"base64://{base64.b64encode(img).decode()}"), + MessageSegment.image( + f"base64://{base64.b64encode(img).decode()}" + ), ) diff --git a/src/plugins/github/plugins/github_reply/link.py b/src/plugins/github/plugins/github_reply/link.py index 9b057ed..0ed0db0 100644 --- a/src/plugins/github/plugins/github_reply/link.py +++ b/src/plugins/github/plugins/github_reply/link.py @@ -18,7 +18,9 @@ from ...libs.redis import MessageInfo from ...utils import send_github_message from . import KEY_GITHUB_REPLY, config, is_github_reply -link = on_command("link", is_github_reply, priority=config.github_command_priority) +link = on_command( + "link", is_github_reply, priority=config.github_command_priority +) link.__doc__ = """ /link 回复机器人一条github信息,给出对应链接 diff --git a/src/plugins/github/plugins/github_repo/__init__.py b/src/plugins/github/plugins/github_repo/__init__.py index cb622ff..c7aff5a 100644 --- a/src/plugins/github/plugins/github_repo/__init__.py +++ b/src/plugins/github/plugins/github_repo/__init__.py @@ -16,7 +16,12 @@ from typing import Dict from nonebot import on_regex from nonebot.typing import T_State from httpx import HTTPStatusError, TimeoutException -from nonebot.adapters.cqhttp import Bot, MessageEvent, MessageSegment, GroupMessageEvent +from nonebot.adapters.cqhttp import ( + Bot, + MessageEvent, + MessageSegment, + GroupMessageEvent, +) from ...libs.repo import get_repo from ... import github_config as config diff --git a/src/plugins/github/plugins/github_subscribe/__init__.py b/src/plugins/github/plugins/github_subscribe/__init__.py index 5bbf7ff..5ab20ac 100644 --- a/src/plugins/github/plugins/github_subscribe/__init__.py +++ b/src/plugins/github/plugins/github_subscribe/__init__.py @@ -97,7 +97,9 @@ else: elif e.response.status_code == 404: await subscribe.reject(f"仓库名 {owner}/{repo_name} 不存在!请重新发送或取消") return - logger.opt(colors=True, exception=e).error(f"github_subscribe: create_hook") + logger.opt(colors=True, exception=e).error( + f"github_subscribe: create_hook" + ) await subscribe.finish("订阅仓库时发生错误,请联系开发者或重试") return diff --git a/src/plugins/nonebot_plugin_sentry/config.py b/src/plugins/nonebot_plugin_sentry/config.py index a7ae9ba..346e1f8 100644 --- a/src/plugins/nonebot_plugin_sentry/config.py +++ b/src/plugins/nonebot_plugin_sentry/config.py @@ -32,7 +32,9 @@ class Config(BaseSettings): sentry_with_locals: bool = True sentry_ca_certs: Optional[str] = None sentry_before_send: Optional[Callable[[Any, Any], Optional[Any]]] = None - sentry_before_breadcrumb: Optional[Callable[[Any, Any], Optional[Any]]] = None + sentry_before_breadcrumb: Optional[ + Callable[[Any, Any], Optional[Any]] + ] = None sentry_transport: Optional[Any] = None sentry_http_proxy: Optional[str] = None sentry_https_proxy: Optional[str] = None diff --git a/src/plugins/nonebot_plugin_status/__init__.py b/src/plugins/nonebot_plugin_status/__init__.py index b1eea4e..e98e7d6 100644 --- a/src/plugins/nonebot_plugin_status/__init__.py +++ b/src/plugins/nonebot_plugin_status/__init__.py @@ -25,7 +25,8 @@ status_config = Config(**global_config.dict()) command = on_command( "状态", - permission=(status_config.server_status_only_superusers or None) and SUPERUSER, + permission=(status_config.server_status_only_superusers or None) + and SUPERUSER, priority=10, ) @@ -78,7 +79,8 @@ async def _poke(bot: Bot, event: Event, state: T_State) -> bool: poke = on_message( _poke, - permission=(status_config.server_status_only_superusers or None) and SUPERUSER, + permission=(status_config.server_status_only_superusers or None) + and SUPERUSER, priority=10, ) poke.handle()(server_status) diff --git a/src/plugins/nonebot_plugin_status/data_source.py b/src/plugins/nonebot_plugin_status/data_source.py index 977676f..3e6990c 100644 --- a/src/plugins/nonebot_plugin_status/data_source.py +++ b/src/plugins/nonebot_plugin_status/data_source.py @@ -29,7 +29,9 @@ def memory_status() -> float: def disk_usage() -> Dict[str, psutil._common.sdiskusage]: disk_parts = psutil.disk_partitions() - disk_usages = {d.mountpoint: psutil.disk_usage(d.mountpoint) for d in disk_parts} + disk_usages = { + d.mountpoint: psutil.disk_usage(d.mountpoint) for d in disk_parts + } return disk_usages diff --git a/src/plugins/redis_provider/__init__.py b/src/plugins/redis_provider/__init__.py index ed3ec1e..7cf4ed2 100644 --- a/src/plugins/redis_provider/__init__.py +++ b/src/plugins/redis_provider/__init__.py @@ -52,7 +52,9 @@ def get_cache(sign: str) -> Any: def save_cache(sign: str, cache: Any, ex: Optional[timedelta] = None) -> None: - redis_client.set(CACHE_KEY_FORMAT.format(signature=sign), pickle.dumps(cache), ex) + redis_client.set( + CACHE_KEY_FORMAT.format(signature=sign), pickle.dumps(cache), ex + ) # Export something for other plugin