Use the walrus operator when assigning and checking for None.
This commit is contained in:
+5
-10
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user