feat: 完善类型注释,增加 mypy 类型检测

This commit is contained in:
Nanmi
2023-07-16 17:57:18 +08:00
parent e5bdc63323
commit 745e59c875
18 changed files with 116 additions and 90 deletions

View File

@@ -39,10 +39,10 @@ async def update_dy_aweme_comment(aweme_id: str, comment_item: Dict):
if aweme_id != comment_aweme_id:
print(f"comment_aweme_id: {comment_aweme_id} != aweme_id: {aweme_id}")
return
user_info = comment_item.get("user")
user_info = comment_item.get("user", {})
comment_id = comment_item.get("cid")
avatar_info = user_info.get("avatar_medium") or user_info.get("avatar_300x300") or user_info.get(
"avatar_168x168") or user_info.get("avatar_thumb") or {}
avatar_info = user_info.get("avatar_medium", {}) or user_info.get("avatar_300x300", {}) or user_info.get(
"avatar_168x168", {}) or user_info.get("avatar_thumb", {}) or {}
local_db_item = {
"comment_id": comment_id,
"create_time": comment_item.get("create_time"),

View File

@@ -1,4 +1,4 @@
from typing import Dict
from typing import Dict, List
from tools import utils
@@ -7,7 +7,7 @@ async def update_xhs_note(note_item: Dict):
note_id = note_item.get("note_id")
user_info = note_item.get("user", {})
interact_info = note_item.get("interact_info")
image_list = note_item.get("image_list")
image_list: List[Dict]= note_item.get("image_list", [])
local_db_item = {
"note_id": note_item.get("note_id"),
@@ -20,7 +20,7 @@ async def update_xhs_note(note_item: Dict):
"nickname": user_info.get("nickname"),
"avatar": user_info.get("avatar"),
"ip_location": note_item.get("ip_location", ""),
"image_list": ','.join([img.get('url') for img in image_list]),
"image_list": ','.join([img.get('url','') for img in image_list]),
"last_modify_ts": utils.get_current_timestamp(),
}
# do something ...
@@ -28,7 +28,7 @@ async def update_xhs_note(note_item: Dict):
async def update_xhs_note_comment(note_id: str, comment_item: Dict):
user_info = comment_item.get("user_info")
user_info = comment_item.get("user_info", {})
comment_id = comment_item.get("id")
local_db_item = {
"comment_id": comment_id,