chore: ruff 代码检查与修复
130 issues auto-fixed (import ordering, UP045/UP006 type annotations), 33 issues manually fixed (E712/E501/E402/E722 + N818 rename + per-file wechat ignore for N8xx naming conventions). All 33 tests pass.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import xml.etree.cElementTree as ET
|
||||
from typing import Optional
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from app.wechat.crypto import WXBizMsgCrypt
|
||||
from app.config import settings
|
||||
from app.wechat.crypto import WXBizMsgCrypt
|
||||
|
||||
|
||||
class WeChatMessageHandler:
|
||||
@@ -15,7 +14,7 @@ class WeChatMessageHandler:
|
||||
|
||||
def verify_url(
|
||||
self, msg_signature: str, timestamp: str, nonce: str, echostr: str
|
||||
) -> Optional[str]:
|
||||
) -> str | None:
|
||||
ret, sEchoStr = self.wxcpt.VerifyURL(
|
||||
msg_signature, timestamp, nonce, echostr
|
||||
)
|
||||
@@ -33,7 +32,7 @@ class WeChatMessageHandler:
|
||||
msg_signature: str,
|
||||
timestamp: str,
|
||||
nonce: str,
|
||||
) -> Optional[ET.Element]:
|
||||
) -> ET.Element | None:
|
||||
ret, xml_content = self.wxcpt.DecryptMsg(
|
||||
post_data, msg_signature, timestamp, nonce
|
||||
)
|
||||
@@ -43,16 +42,16 @@ class WeChatMessageHandler:
|
||||
|
||||
def encrypt_response(
|
||||
self, response_xml: str, nonce: str, timestamp: str
|
||||
) -> Optional[str]:
|
||||
) -> str | None:
|
||||
ret, encrypted = self.wxcpt.EncryptMsg(response_xml, nonce, timestamp)
|
||||
if ret == 0:
|
||||
return encrypted
|
||||
return None
|
||||
|
||||
def handle_event(
|
||||
self, event: str, event_key: Optional[str], from_user: str
|
||||
) -> Optional[str]:
|
||||
self, event: str, event_key: str | None, from_user: str
|
||||
) -> str | None:
|
||||
return None
|
||||
|
||||
def handle_text(self, content: str, from_user: str) -> Optional[str]:
|
||||
def handle_text(self, content: str, from_user: str) -> str | None:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user