Commit 20e78bc

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-06-18 06:49:02
style: fix some lint error [skip ci]
1 parent 92388da
src/asr/voice_recognition.py
@@ -100,7 +100,14 @@ async def voice_to_text(
     if equal_prefix(message.text, prefix=[PREFIX.ASR]) and not message.reply_to_message:
         await send2tg(client, message, texts=HELP, **kwargs)
         return
-    if not (trigger_message := get_trigger_message(message, asr_need_prefix, asr_skip_voice, asr_skip_audio, asr_skip_video)):
+    trigger_message = get_trigger_message(
+        message,
+        asr_need_prefix=asr_need_prefix,
+        asr_skip_voice=asr_skip_voice,
+        asr_skip_audio=asr_skip_audio,
+        asr_skip_video=asr_skip_video,
+    )
+    if not trigger_message:
         return
     this_info = parse_msg(message, silent=True)
     trigger_info = parse_msg(trigger_message, silent=True)
@@ -239,6 +246,7 @@ async def asr_file(
 
 def get_trigger_message(
     message: Message,
+    *,
     asr_need_prefix: bool | None = None,
     asr_skip_voice: bool | None = None,
     asr_skip_audio: bool | None = None,
src/llm/gemini.py
@@ -136,7 +136,6 @@ async def gemini_stream(
     Returns:
         dict: {"texts": str, "thoughts": str, "prefix": str, "model_name": str, "sent_messages": list[Message]}
     """
-    # ruff: noqa: RUF001, RUF003
     if prefix is None:
         prefix = f"🤖**{model_name}**:{BOT_TIPS}\n"
     answers = ""  # all model responses
src/llm/gpt.py
@@ -128,7 +128,6 @@ async def gpt_response(
     Returns:
         dict: {"texts": str, "thoughts": str, "prefix": str, "model_name": str, "sent_messages": list[Message]}
     """
-    # ruff: noqa: RET502, RET503
     info = parse_msg(message, silent=True, use_cache=False)
     # send docs if message == "/ai"
     if info["mtype"] == "text" and equal_prefix(info["text"], prefix=PREFIX.GPT):
src/llm/response_stream.py
@@ -32,7 +32,6 @@ async def send_to_gpt_stream(
     Returns:
         dict: {"texts": str, "thoughts": str, "prefix": str, "model_name": str, "sent_messages": list[Message]}
     """
-    # ruff: noqa: RUF001, RUF003
     prefix = f"🤖**{config['friendly_name']}**:{BOT_TIPS}\n"
     final = {"prefix": prefix, "model_name": config["friendly_name"], "sent_messages": [status]}
     try:
src/messages/parser.py
@@ -20,7 +20,6 @@ def parse_msg(message: Message, *, silent: bool = False, verbose: bool = False,
 
     Abbreviations: c = chat, m = message, u = user
     """
-    # ruff: noqa: B009
     if use_cache and (cached := cache.get(f"parse_msg-{message.chat.id}-{message.id}")):
         return cached
     if not silent and verbose:
@@ -141,7 +140,6 @@ def parse_chat(chat: Chat, *, use_cache: bool = True) -> dict:
 
     Abbreviations: c = chat, m = message, u = user
     """
-    # ruff: noqa: B009
     if use_cache and (cached := cache.get(f"parse_chat-{chat.id}")):
         return cached
     ctype = glom(chat, "type.name", default="") or ""
src/others/raw_img_file.py
@@ -22,7 +22,7 @@ async def convert_raw_img_file(client: Client, message: Message, *, convert_need
     if equal_prefix(message.text, prefix=[PREFIX.CONVERT]) and not message.reply_to_message:
         await send2tg(client, message, texts=HELP, **kwargs)
         return
-    if not (trigger_message := get_trigger_message(message, convert_need_prefix)):
+    if not (trigger_message := get_trigger_message(message, convert_need_prefix=convert_need_prefix)):
         return
     info = parse_msg(trigger_message)
     if info["mime_type"] not in ["image/png", "image/jpeg", "image/heic"]:
@@ -42,10 +42,7 @@ async def convert_raw_img_file(client: Client, message: Message, *, convert_need
         logger.exception(e)
 
 
-def get_trigger_message(
-    message: Message,
-    convert_need_prefix: bool | None = None,
-) -> Message | None:
+def get_trigger_message(message: Message, *, convert_need_prefix: bool | None = None) -> Message | None:
     """Check if the message is triggerable for converting.
 
     By default, "/convert" prefix is needed in in Group & Channel & Bot chats to trigger this function.
src/price/entrypoint.py
@@ -169,7 +169,7 @@ async def match_symbol_category(symbol: str = "", *, crypto_only: bool = False,
     # skip some crypto ETF (e.g. Grayscale Bitcoin Mini Trust use symbol "AMEX:BTC")
     if category.get("crypto") and category.get("tradingview"):
         exchange, coin = tradingview[0][0].split(":")
-        if exchange == "AMEX" and category["crypto"].startswith(coin):  # hit crypto ETF
+        if exchange == "AMEX" and category.get("crypto", "").startswith(coin):  # hit crypto ETF
             tradingview = []
             del category["tradingview"]
 
src/config.py
@@ -7,7 +7,6 @@ from pathlib import Path
 from cacheout import Cache
 from cutword import Cutter
 
-# ruff: noqa: RUF001
 # init some global instances
 cache = Cache(ttl=0, maxsize=2048)
 semaphore = asyncio.Semaphore(8)  # max 8 concurrent downloads
src/handler.py
@@ -74,7 +74,6 @@ async def handle_utilities(
         asr (bool, optional): Enable ASR. Defaults to True.
         audio (bool, optional): Enable Video -> Audio. Defaults to True.
         danmu (bool, optional): Enable Query Danmu database. Defaults to True.
-        save_history (bool, optional): Enable save chat history. Defaults to True.
         google (bool, optional): Enable Google Search. Defaults to True.
         ytb (bool, optional): Enable YouTube Search. Defaults to True.
         history (bool, optional): Enable History Search. Defaults to True.
src/main.py
@@ -33,8 +33,6 @@ from permission import check_permission
 from price.entrypoint import match_symbol_category
 from utils import cleanup_old_files, nowdt, to_int
 
-# ruff: noqa: RUF001
-
 
 async def main():
     app = Client(
src/permission.py
@@ -11,7 +11,6 @@ from config import ENABLE, TID, cache
 from utils import i_am_bot, slim_cid, to_int, true
 
 
-# ruff: noqa: SIM103
 async def check_permission(client: Client, message: Message) -> dict:
     """Check if the user has permission to use the bot."""
     ctype = message.chat.type.name if message.chat and message.chat.type else ""
pyproject.toml
@@ -87,6 +87,7 @@ ignore = [
   "S311",
   "TD",
   "FIX002",
+  "PLC0415",
   "S608",
 ]
 select = ["ALL"]