From 7d62c5b0099aa4fae6ae3ab41e5aa949166edf5e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 03:11:10 +0800 Subject: [PATCH] refactor: use identity check for comparison to a singleton (#28) Comparisons to the singleton objects, like `True`, `False`, and `None`, should be done with identity, not equality. Use `is` or `is not`. Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- src/plugins/nonebot_plugin_addFriend/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/nonebot_plugin_addFriend/__init__.py b/src/plugins/nonebot_plugin_addFriend/__init__.py index 7c31e52..5196074 100644 --- a/src/plugins/nonebot_plugin_addFriend/__init__.py +++ b/src/plugins/nonebot_plugin_addFriend/__init__.py @@ -58,7 +58,7 @@ async def _(bot: Bot, event: RequestEvent): # 黑名单警告,转发给设定的人 await sendMsg(bot, config[bot.self_id]['recipientList'], msg+status, 0) forwardId = config[bot.self_id]["blackDict"]["forward"].get(id) - if forwardId != None and autoType == "group": + if forwardId is not None and autoType == "group": friendList = await getReferIdList(bot, 'user_id') if forwardId in friendList: await bot.send_private_msg(user_id=forwardId, message=msg+status) @@ -226,7 +226,7 @@ async def _(bot: Bot, event: MessageEvent, args: Message = CommandArg()): # 预处理完毕,开始设置参数 QQOrGroupId = argsText.split()[0] print(QQOrGroupId) - if requestorDict[bot.self_id][autoType].get(QQOrGroupId) == None: + if requestorDict[bot.self_id][autoType].get(QQOrGroupId) is None: await addFriend.finish('没有此请求') flag = requestorDict[bot.self_id][autoType][QQOrGroupId]['flag'] @@ -255,7 +255,7 @@ async def _(bot: Bot, event: MessageEvent, args: Message = CommandArg()): if int(QQOrGroupId) in friendList: status = '已经添加成功,勿复添加' else: - if len(argsText) >= 2 and argsText[1] != '' and approve == True: + if len(argsText) >= 2 and argsText[1] != '' and approve is True: remark = argsText[1] # 备注似乎无用 await bot.set_friend_add_request(flag=flag, approve=approve, remark=remark)