Use the walrus operator when assigning and checking for None.

This commit is contained in:
2025-03-12 09:35:44 -04:00
parent 29a163ec46
commit 304b089113
2 changed files with 17 additions and 45 deletions
+5 -10
View File
@@ -45,8 +45,7 @@ class GetCog(commands.Cog, name="Get command."):
)
with Session(engine) as session:
category = session.scalar(stmt)
if category is None:
if (category := session.scalar(stmt)) is None:
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
return
@@ -77,8 +76,7 @@ class GetCog(commands.Cog, name="Get command."):
)
with Session(engine) as session:
category = session.scalar(stmt)
if category is None:
if (category := session.scalar(stmt)) is None:
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
return
@@ -107,8 +105,7 @@ class GetCog(commands.Cog, name="Get command."):
)
with Session(engine) as session:
category = session.scalar(stmt)
if category is None:
if (category := session.scalar(stmt)) is None:
await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
return
@@ -134,8 +131,7 @@ class GetCog(commands.Cog, name="Get command."):
stmt = select(CategoryGroup).where(col(CategoryGroup.id) == int(group_id))
with Session(engine) as session:
group = session.scalar(stmt)
if group is None:
if (group := session.scalar(stmt)) is None:
await interaction.response.send_message("Group was not found.", ephemeral=True)
return
@@ -161,8 +157,7 @@ class GetCog(commands.Cog, name="Get command."):
stmt = select(CategoryGroup).where(col(CategoryGroup.id) == int(group_id))
with Session(engine) as session:
group = session.scalar(stmt)
if group is None:
if (group := session.scalar(stmt)) is None:
await interaction.response.send_message("Group was not found.", ephemeral=True)
return