From 9d913b86ee98f36ee15b9f49913ae50795545055 Mon Sep 17 00:00:00 2001 From: hikariatama Date: Mon, 26 Sep 2022 12:31:37 +0000 Subject: [PATCH] Deepsource + sourcery fixes --- hikka/configurator.py | 5 +---- hikka/dispatcher.py | 6 +++--- hikka/inline/form.py | 3 ++- hikka/loader.py | 9 +++++---- hikka/log.py | 2 +- hikka/modules/hikka_security.py | 4 +--- web-resources/static/root.js | 8 ++++---- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/hikka/configurator.py b/hikka/configurator.py index deae0dd..3480184 100755 --- a/hikka/configurator.py +++ b/hikka/configurator.py @@ -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""" diff --git a/hikka/dispatcher.py b/hikka/dispatcher.py index a2e6652..ecc49f1 100755 --- a/hikka/dispatcher.py +++ b/hikka/dispatcher.py @@ -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 ( diff --git a/hikka/inline/form.py b/hikka/inline/form.py index 8eba5e3..0499a70 100644 --- a/hikka/inline/form.py +++ b/hikka/inline/form.py @@ -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 diff --git a/hikka/loader.py b/hikka/loader.py index 6c95678..946636a 100644 --- a/hikka/loader.py +++ b/hikka/loader.py @@ -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) diff --git a/hikka/log.py b/hikka/log.py index f6a2f2c..791bc58 100755 --- a/hikka/log.py +++ b/hikka/log.py @@ -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 diff --git a/hikka/modules/hikka_security.py b/hikka/modules/hikka_security.py index 319ba21..3360376 100755 --- a/hikka/modules/hikka_security.py +++ b/hikka/modules/hikka_security.py @@ -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")) diff --git a/web-resources/static/root.js b/web-resources/static/root.js index 0e897cc..65fc1c0 100644 --- a/web-resources/static/root.js +++ b/web-resources/static/root.js @@ -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); })