Deepsource + sourcery fixes

pull/1/head
hikariatama 2022-09-26 12:31:37 +00:00
parent 1b1ebfbe4d
commit 9d913b86ee
7 changed files with 17 additions and 20 deletions

View File

@ -53,10 +53,7 @@ class TDialog:
print(query) print(query)
print() print()
inp = _safe_input("Please enter your response, or type nothing to cancel: ") inp = _safe_input("Please enter your response, or type nothing to cancel: ")
if inp == "" or inp is None: return (False, "Cancelled") if not inp else (True, inp)
return False, "Cancelled"
return True, inp
def msgbox(self, msg: str) -> bool: def msgbox(self, msg: str) -> bool:
"""Print some info""" """Print some info"""

View File

@ -506,7 +506,7 @@ class CommandDispatcher:
and ( and (
not isinstance(message, Message) not isinstance(message, Message)
or isinstance(func.startswith, str) or isinstance(func.startswith, str)
and not message.raw_text.startswith(getattr(func, "startswith")) and not message.raw_text.startswith(func.startswith)
) )
) )
or ( or (
@ -514,7 +514,7 @@ class CommandDispatcher:
and ( and (
not isinstance(message, Message) not isinstance(message, Message)
or isinstance(func.endswith, str) or isinstance(func.endswith, str)
and not message.raw_text.endswith(getattr(func, "endswith")) and not message.raw_text.endswith(func.endswith)
) )
) )
or ( or (
@ -522,7 +522,7 @@ class CommandDispatcher:
and ( and (
not isinstance(message, Message) not isinstance(message, Message)
or isinstance(func.contains, str) or isinstance(func.contains, str)
and getattr(func, "contains") not in message.raw_text and func.contains not in message.raw_text
) )
) )
or ( or (

View File

@ -249,7 +249,8 @@ class Form(InlineUnit):
if not isinstance(force_me, bool): if not isinstance(force_me, bool):
logger.error( logger.error(
"Invalid type for `force_me`. Expected `bool`, got `%s`", type(force_me) "Invalid type for `force_me`. Expected `bool`, got `%s`",
type(force_me),
) )
return False return False

View File

@ -580,8 +580,10 @@ class Modules:
self.secure_boot = self._db.get(__name__, "secure_boot", False) self.secure_boot = self._db.get(__name__, "secure_boot", False)
if not self.secure_boot: external_mods = (
external_mods = [ []
if self.secure_boot
else [
os.path.join(LOADED_MODULES_DIR, mod) os.path.join(LOADED_MODULES_DIR, mod)
for mod in filter( for mod in filter(
lambda x: ( lambda x: (
@ -591,8 +593,7 @@ class Modules:
os.listdir(LOADED_MODULES_DIR), os.listdir(LOADED_MODULES_DIR),
) )
] ]
else: )
external_mods = []
loaded = [] loaded = []
loaded += await self._register_modules(mods) loaded += await self._register_modules(mods)

View File

@ -255,7 +255,7 @@ class TelegramLogsHandler(logging.Handler):
for client_id in self._mods for client_id in self._mods
} }
for client_id, exceptions in self._exc_queue.items(): for exceptions in self._exc_queue.values():
for exc in exceptions: for exc in exceptions:
await exc await exc

View File

@ -1083,15 +1083,13 @@ class HikkaSecurityMod(loader.Module):
if not message.is_private and not message.is_reply: if not message.is_private and not message.is_reply:
await utils.answer(message, self.strings("no_target")) await utils.answer(message, self.strings("no_target"))
return return
if message.is_private: if message.is_private:
target = await self._client.get_entity(message.peer_id) target = await self._client.get_entity(message.peer_id)
elif message.is_reply: elif message.is_reply:
target = await self._client.get_entity( target = await self._client.get_entity(
(await message.get_reply_message()).sender_id (await message.get_reply_message()).sender_id
) )
else:
await utils.answer(message, self.strings("no_target"))
return
if not self._client.dispatcher.security.remove_rules("user", target.id): if not self._client.dispatcher.security.remove_rules("user", target.id):
await utils.answer(message, self.strings("no_rules")) await utils.answer(message, self.strings("no_rules"))

View File

@ -127,8 +127,8 @@ function tg_code() {
clearCanvas: true, clearCanvas: true,
} }
}); });
anim.addEventListener("complete", function () { anim.addEventListener("complete", () => {
setTimeout(function () { setTimeout(() => {
anim.goToAndPlay(0); anim.goToAndPlay(0);
}, 2000); }, 2000);
}) })
@ -282,8 +282,8 @@ function process_next() {
clearCanvas: true, clearCanvas: true,
} }
}); });
anim2.addEventListener("complete", function () { anim2.addEventListener("complete", () => {
setTimeout(function () { setTimeout(() => {
anim2.goToAndPlay(0); anim2.goToAndPlay(0);
}, 2000); }, 2000);
}) })