style: format code with black

Format code with black

This commit fixes the style issues introduced in 4e68539 according to the output
from Black.

Details: None
This commit is contained in:
deepsource-autofix[bot] 2023-09-08 20:53:51 +00:00 committed by GitHub
parent 4e685393de
commit aa86e211e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 30 deletions

View file

@ -34,8 +34,6 @@ class Animals(commands.Cog):
embed = discord.Embed(
title=animal.capitalize(),
colour=discord.Colour.orange(),
).set_image(
url="attachment://image.png"
)
).set_image(url="attachment://image.png")
await ctx.reply(embed=embed, file=animal_file, mention_author=False)

View file

@ -16,7 +16,9 @@ class Img(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._overlays = {
"bubble": Image.open(os.path.join(ASSETS_PATH, "bubble.png")).convert("RGBA"),
"bubble": Image.open(os.path.join(ASSETS_PATH, "bubble.png")).convert(
"RGBA"
),
"gang": Image.open(os.path.join(ASSETS_PATH, "gang.png")).convert("RGBA"),
}
@ -29,8 +31,10 @@ class Img(commands.Cog):
# Check if image should be processed
async with ctx.typing():
if not style or style not in IMAGE_OVERLAYS:
error = "That is not a valid option! Valid options are:\n" \
f"`{', '.join(IMAGE_OVERLAYS)}`"
error = (
"That is not a valid option! Valid options are:\n"
f"`{', '.join(IMAGE_OVERLAYS)}`"
)
await ctx.reply(embed=error_message(error))
return
@ -40,20 +44,27 @@ class Img(commands.Cog):
return
# Extracts file extension from filename
if not ctx.message.attachments[0].filename.split(".")[-1].lower() in IMAGE_EXTENSIONS:
error = "Unsupported file type! Supported file types are:\n" \
f"`{', '.join(IMAGE_EXTENSIONS)}`"
if (
not ctx.message.attachments[0].filename.split(".")[-1].lower()
in IMAGE_EXTENSIONS
):
error = (
"Unsupported file type! Supported file types are:\n"
f"`{', '.join(IMAGE_EXTENSIONS)}`"
)
await ctx.reply(embed=error_message(error))
return
if ctx.message.attachments[0].size > 8_000_000:
error = "That image is too big! Please use an image that is less than 8MB."
error = (
"That image is too big! Please use an image that is less than 8MB."
)
await ctx.reply(embed=error_message(error))
return
if (
not 0 < ctx.message.attachments[0].width <= 3500 or
not 0 < ctx.message.attachments[0].height <= 3500
not 0 < ctx.message.attachments[0].width <= 3500
or not 0 < ctx.message.attachments[0].height <= 3500
):
error = "Image must be at least 1x1 and under 3500x3500!"
await ctx.reply(embed=error_message(error))
@ -73,27 +84,24 @@ class Img(commands.Cog):
# The bubble is resized twice as for some reason .copy() doesn't work
message_attachment.paste(
self._overlays["bubble"].resize(
(
message_attachment.width,
self._overlays["bubble"].height
)
(message_attachment.width, self._overlays["bubble"].height)
),
(0, 0),
self._overlays["bubble"].resize(
(
message_attachment.width,
self._overlays["bubble"].height
)
(message_attachment.width, self._overlays["bubble"].height)
),
)
elif style == "gang":
message_attachment.paste(
self._overlays["gang"],
(
((message_attachment.width - self._overlays["gang"].width) // 2),
(message_attachment.height - self._overlays["gang"].height)
(
(message_attachment.width - self._overlays["gang"].width)
// 2
),
(message_attachment.height - self._overlays["gang"].height),
),
self._overlays["gang"]
self._overlays["gang"],
)
message_file = BytesIO()
@ -102,9 +110,13 @@ class Img(commands.Cog):
message_file = discord.File(message_file, filename="image.png")
time_taken = datetime.datetime.now() - start_time
embed = discord.Embed(title=style.capitalize(), colour=discord.Colour.orange())\
.set_image(url="attachment://image.png")\
.set_footer(text=f"{message_attachment.width}x{message_attachment.height}, "
f"{time_taken.microseconds / 1000}ms")
embed = (
discord.Embed(title=style.capitalize(), colour=discord.Colour.orange())
.set_image(url="attachment://image.png")
.set_footer(
text=f"{message_attachment.width}x{message_attachment.height}, "
f"{time_taken.microseconds / 1000}ms"
)
)
await ctx.reply(embed=embed, file=message_file, mention_author=False)

View file

@ -47,9 +47,7 @@ TINYFOX_ANIMALS = [
"woof",
]
IMAGE_EXTENSIONS = [
"png", "jpg", "jpeg", "webp"
]
IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp"]
IMAGE_OVERLAYS = [
"bubble",