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:
2026-05-09 14:28:09 +08:00
parent 02ea794015
commit 7455d7e426
33 changed files with 147 additions and 114 deletions
+6 -6
View File
@@ -1,18 +1,18 @@
import hashlib
from datetime import datetime
from typing import Any, Dict, List
from typing import Any
from urllib.parse import urljoin
from bs4 import BeautifulSoup
def parse_gxgp_api_response(
response_data: Dict[str, Any],
response_data: dict[str, Any],
source_code: str,
source_name: str,
crawled_at: datetime,
category_id: int,
) -> List[Dict[str, Any]]:
) -> list[dict[str, Any]]:
if not response_data.get("success"):
return []
data = response_data.get("result", {}).get("data", {})
@@ -62,7 +62,7 @@ def parse_gxgp_api_response(
return results
def extract_pagination(response_data: Dict[str, Any]) -> Dict[str, Any]:
def extract_pagination(response_data: dict[str, Any]) -> dict[str, Any]:
data = response_data.get("result", {}).get("data", {})
return {
"total": data.get("total", 0),
@@ -75,7 +75,7 @@ def extract_pagination(response_data: Dict[str, Any]) -> Dict[str, Any]:
}
def parse_dahuagov_html(html: str, crawled_at: datetime) -> List[Dict[str, Any]]:
def parse_dahuagov_html(html: str, crawled_at: datetime) -> list[dict[str, Any]]:
soup = BeautifulSoup(html, "html.parser")
lists = soup.find_all("ul", class_="more-list")
if not lists:
@@ -131,7 +131,7 @@ def parse_dahuagov_html(html: str, crawled_at: datetime) -> List[Dict[str, Any]]
return results
def _generate_hash(ann: Dict[str, Any]) -> str:
def _generate_hash(ann: dict[str, Any]) -> str:
content = (
f"{ann['title']}|{ann['publish_date'].strftime('%Y-%m-%d')}"
f"|{ann['purchase_name']}|{ann['content_url']}|{ann['source_code']}"