Skip to content

Commit

Permalink
reformat use ruff & make ruff happy
Browse files Browse the repository at this point in the history
  • Loading branch information
lgc2333 committed Feb 10, 2024
1 parent 30824bc commit 8fa9235
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 3 additions & 1 deletion marketplace/scripts/gen_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def main():
info_url = f"market/replies/{dir_name}"
br_desc = meta.desc.replace("\n", "<br />")

sidebar_md = f' - [{meta.name}]({info_url} "{meta.name} | AutoReply 回复市场")'
sidebar_md = (
f' - [{meta.name}]({info_url} "{meta.name} | AutoReply 回复市场")'
)
market_list_md = (
f"| [{meta.name}]({info_url}) "
f"| [{meta.author}]({meta.author_link}) "
Expand Down
3 changes: 1 addition & 2 deletions nonebot_plugin_autoreply/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from nonebot.plugin import PluginMetadata

from . import __main__ as __main__
from .config import ConfigModel
from .config import reload_replies as reload_replies
from .config import ConfigModel, reload_replies as reload_replies

__version__ = "0.2.11"
__plugin_meta__ = PluginMetadata(
Expand Down
10 changes: 6 additions & 4 deletions nonebot_plugin_autoreply/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Union,
cast,
)
from typing_extensions import TypeVarTuple, Unpack

from nonebot import on_command, on_message, on_notice
from nonebot.adapters.onebot.v11 import (
Expand All @@ -27,7 +28,6 @@
from nonebot.matcher import Matcher
from nonebot.permission import SUPERUSER
from nonebot.typing import T_State
from typing_extensions import TypeVarTuple, Unpack

from nonebot_plugin_autoreply.util import VarDictType, get_var_dict, replace_message_var

Expand Down Expand Up @@ -115,7 +115,7 @@ def check_message(
msg_plaintext = msg_plaintext.strip()

if match.type == "regex":
flag = re.I if match.ignore_case else 0
flag = re.IGNORECASE if match.ignore_case else 0
match_obj = re.search(match_template, msg_str, flag)
if (not match_obj) and match.allow_plaintext:
match_obj = re.search(match_template, msg_plaintext, flag)
Expand Down Expand Up @@ -223,7 +223,7 @@ async def message_checker(

if not (
check_list(check_filter, filter_checks)[0]
and (match_result := check_list(check_match, match_checks, True))[0]
and (match_result := check_list(check_match, match_checks, is_any=True))[0]
):
continue

Expand Down Expand Up @@ -275,7 +275,9 @@ async def get_reply_msgs(
delay = (delay, delay)

msg = cast(List[ReplyModel], msg)
msgs = [(await get_reply_msgs(x, var_dict, True))[0][0] for x in msg]
msgs = [
(await get_reply_msgs(x, var_dict, refuse_multi=True))[0][0] for x in msg
]
if reply.shuffle:
random.shuffle(msgs)

Expand Down
6 changes: 4 additions & 2 deletions nonebot_plugin_autoreply/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def load_config(path: Path) -> List[ReplyEntryModel]:
content = path.read_text(encoding="u8")

if path.suffix in (".yml", ".yaml"):
obj: list = yaml.load(content, Loader=yaml.FullLoader)
obj: list = yaml.safe_load(content)
else:
obj: list = json.loads(content)

Expand All @@ -138,7 +138,9 @@ def reload_replies() -> Tuple[int, int]:
fail += 1

else:
logger.opt(colors=True).info(f"加载回复配置 <y>{file_name}</y> <l><g>成功</g></l>")
logger.opt(colors=True).info(
f"加载回复配置 <y>{file_name}</y> <l><g>成功</g></l>",
)
success += 1

replies.sort(key=lambda x: x.priority)
Expand Down

0 comments on commit 8fa9235

Please sign in to comment.