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()
inp = _safe_input("Please enter your response, or type nothing to cancel: ")
if inp == "" or inp is None:
return False, "Cancelled"
return True, inp
return (False, "Cancelled") if not inp else (True, inp)
def msgbox(self, msg: str) -> bool:
"""Print some info"""

View File

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

View File

@ -249,7 +249,8 @@ class Form(InlineUnit):
if not isinstance(force_me, bool):
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

View File

@ -580,8 +580,10 @@ class Modules:
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)
for mod in filter(
lambda x: (
@ -591,8 +593,7 @@ class Modules:
os.listdir(LOADED_MODULES_DIR),
)
]
else:
external_mods = []
)
loaded = []
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, exceptions in self._exc_queue.items():
for exceptions in self._exc_queue.values():
for exc in exceptions:
await exc

View File

@ -1083,15 +1083,13 @@ class HikkaSecurityMod(loader.Module):
if not message.is_private and not message.is_reply:
await utils.answer(message, self.strings("no_target"))
return
if message.is_private:
target = await self._client.get_entity(message.peer_id)
elif message.is_reply:
target = await self._client.get_entity(
(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):
await utils.answer(message, self.strings("no_rules"))

View File

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