From 6b1fee77f037c8ddde269b835e99d4436b532f2e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 18:38:34 +0000 Subject: [PATCH 1/3] style: format code with black Format code with black This commit fixes the style issues introduced in 960f452 according to the output from Black. Details: None --- lynxie/commands/e621.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lynxie/commands/e621.py b/lynxie/commands/e621.py index d9caa24..ce6f1a4 100644 --- a/lynxie/commands/e621.py +++ b/lynxie/commands/e621.py @@ -72,7 +72,7 @@ class E621(commands.Cog): embed.add_field( name="Score", value=f"^ {response['posts'][0]['score']['up']} | " - f"v {response['posts'][0]['score']['down']}", + f"v {response['posts'][0]['score']['down']}", ) embed.add_field( name="Favorites", @@ -86,13 +86,14 @@ class E621(commands.Cog): ) embed.add_field( name="Tags", - value=", ".join(response["posts"][0]["tags"]["general"]) or "No tags provided.", + value=", ".join(response["posts"][0]["tags"]["general"]) + or "No tags provided.", inline=False, ) embed.set_footer( text=f"ID: {response['posts'][0]['id']} | " - f"Created: {response['posts'][0]['created_at']}" + f"Created: {response['posts'][0]['created_at']}" ) embed.set_image(url=response["posts"][0]["file"]["url"]) From 678a659ddae8eab1d38dbd0d3f374e6007ce110d Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 21:25:19 +0000 Subject: [PATCH 2/3] refactor: refactor unnecessary `else` / `elif` when `if` block has a `return` statement The use of `else` or `elif` becomes redundant and can be dropped if the last statement under the leading `if` / `elif` block is a `return` statement. In the case of an `elif` after `return`, it can be written as a separate `if` block. For `else` blocks after `return`, the statements can be shifted out of `else`. Please refer to the examples below for reference. Refactoring the code this way can improve code-readability and make it easier to maintain. --- lynxie/commands/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lynxie/commands/image.py b/lynxie/commands/image.py index 43eaded..d89db2d 100644 --- a/lynxie/commands/image.py +++ b/lynxie/commands/image.py @@ -19,10 +19,10 @@ class Img(commands.Cog): async def get_image_attachments(ctx): if ctx.message.attachments: return ctx.message.attachments[0] - elif ctx.message.reference: + if ctx.message.reference: if ctx.message.reference.resolved.attachments: return ctx.message.reference.resolved.attachments[0] - elif ( + if ( ctx.message.reference.resolved.embeds and ctx.message.reference.resolved.embeds[0].image ): From b541817558225cbe3e9f1bc1f6ca10fcf406a623 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 21:25:43 +0000 Subject: [PATCH 3/3] refactor: remove unnecessary f-string It is wasteful to use `f-string` mechanism if there are no expressions to be extrapolated. It is recommended to use regular strings instead. --- lynxie/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lynxie/config.py b/lynxie/config.py index 0b7b9ef..2304a81 100644 --- a/lynxie/config.py +++ b/lynxie/config.py @@ -13,7 +13,7 @@ LYNXIE_PREFIX = "?" DATA_PATH = os.path.join("lynxie", "data") ASSETS_PATH = os.path.join("lynxie", "assets") -DATABASE_URI = f"sqlite:///" + os.path.join(DATA_PATH, "lynxie.db") +DATABASE_URI = "sqlite:///" + os.path.join(DATA_PATH, "lynxie.db") # https://tinyfox.dev/docs/ # TODO: Get list from API instead of hardcoding