Skip to content

Commit

Permalink
Fixing some ruff check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lexicalunit committed Jul 3, 2024
1 parent 048ba27 commit a0fec31
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/spellbot/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,10 @@ def waiting(self, channel_xid: int) -> bool:
return False
if game.status != GameStatus.PENDING.value:
return False
if game.deleted_at is not None:
return False
# Not required because self.game() already filters by posts + channel.
# if not any(post.channel_xid == channel_xid for post in game.posts):
# return False
return True
return game.deleted_at is None

def confirmed(self, channel_xid: int) -> bool:
from spellbot.database import DatabaseSession
Expand Down
4 changes: 1 addition & 3 deletions src/spellbot/services/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,7 @@ def blocked(self, author_xid: int) -> bool:
player_xids = self.game.player_xids
if any(xid in player_xids for xid in users_author_has_blocked):
return True
if any(xid in player_xids for xid in users_who_blocked_author):
return True
return False
return any(xid in player_xids for xid in users_who_blocked_author)

@sync_to_async()
@tracer.wrap()
Expand Down
16 changes: 4 additions & 12 deletions src/spellbot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def bot_can_role(guild: discord.Guild, role: discord.Role | None = None) -> bool
req = "manage_roles"
if not hasattr(perms, req) or not getattr(perms, req):
return False
if role is not None and role > guild.me.top_role:
return False
return True
return not (role is not None and role > guild.me.top_role)


def bot_can_read(channel: MessageableChannel) -> bool:
Expand All @@ -112,9 +110,7 @@ def bot_can_manage_channels(guild: discord.Guild) -> bool:
return False
perms = guild.me.guild_permissions
req = "manage_channels"
if not hasattr(perms, req) or not getattr(perms, req):
return False
return True
return hasattr(perms, req) and getattr(perms, req)


def bot_can_delete_message(message: discord.Message | discord.PartialMessage) -> bool:
Expand All @@ -125,9 +121,7 @@ def bot_can_delete_message(message: discord.Message | discord.PartialMessage) ->
return False
perms = guild.me.guild_permissions
req = "manage_messages"
if hasattr(perms, req) and getattr(perms, req):
return True
return False
return hasattr(perms, req) and getattr(perms, req)


def bot_can_delete_channel(channel: MessageableChannel) -> bool:
Expand Down Expand Up @@ -156,9 +150,7 @@ def bot_can_read_messages(guild: discord.Guild) -> bool:
return False
perms = guild.me.guild_permissions
req = "read_messages"
if not hasattr(perms, req) or not getattr(perms, req):
return False
return True
return hasattr(perms, req) and getattr(perms, req)


def is_admin(interaction: discord.Interaction) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_codebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class TestCodebase:
def test_annotations(self) -> None:
"""Checks that all python modules import annotations from future."""
chdir(REPO_ROOT)
output = getoutput(
output = getoutput( # noqa: S605
(
r"find . -type d \( " # noqa: S607, S605
r"/usr/bin/find . -type d \( "
r" -path ./env -o "
r" -path ./venv -o "
r" -path ./.venv -o "
Expand Down

0 comments on commit a0fec31

Please sign in to comment.