Skip to content

Commit 22d96cd

Browse files
authored
Merge pull request CSS360-2026-Winter#163 from gracefulliberty/black-update
Check code formatting in CI
2 parents d1cf48a + 66bc8b5 commit 22d96cd

4 files changed

Lines changed: 20 additions & 24 deletions

File tree

.github/workflows/pylint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pylint
1+
name: Pylint and Format
22

33
on:
44
push:
@@ -24,7 +24,9 @@ jobs:
2424
run: |
2525
python -m pip install --upgrade pip
2626
python -m pip install pylint
27+
python -m pip install black
2728
python -m pip install .[test]
2829
- name: Analysing the code with pylint
2930
run: |
3031
pylint $(git ls-files '*.py')
32+
black --check $(git ls-files '*.py')

controllers/uno_cog.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def play(
159159
except (discord.Forbidden, discord.HTTPException):
160160
pass
161161

162-
# pylint: disable=duplicate-code
162+
# pylint: disable=duplicate-code
163163
@app_commands.command(name="kick", description="Kick a player from the game.")
164164
async def kick(self, interaction: discord.Interaction, player: discord.Member):
165165
"""Allows the host to remove a player from the current game."""
@@ -172,33 +172,27 @@ async def kick(self, interaction: discord.Interaction, player: discord.Member):
172172

173173
if interaction.user.id != lobby.user.id:
174174
raise GameError(
175-
"Only the host can kick players.",
176-
private=True,
177-
title="Host Only"
175+
"Only the host can kick players.", private=True, title="Host Only"
178176
)
179177

180178
if player.id not in lobby.game.players():
181179
raise GameError(
182180
"That player is not in the game.",
183181
private=True,
184-
title="Player Not Found"
182+
title="Player Not Found",
185183
)
186184

187185
self.game_service.kick_player(cid, player.id)
188186

189187
except GameError as e:
190188
embed = self._renderer.lobby_views.error_embed(
191-
"Game Error" if e.title == "" else e.title,
192-
str(e)
189+
"Game Error" if e.title == "" else e.title, str(e)
193190
)
194191
await interaction.followup.send(embeds=[embed], ephemeral=e.private)
195192
return
196193

197194
await self._renderer.update_by_message_id(
198-
self.bot,
199-
cid,
200-
lobby.main_message,
201-
lobby
195+
self.bot, cid, lobby.main_message, lobby
202196
)
203197

204198
try:
@@ -207,8 +201,7 @@ async def kick(self, interaction: discord.Interaction, player: discord.Member):
207201
pass
208202

209203
await interaction.followup.send(
210-
f"{player.display_name} was kicked from the game.",
211-
ephemeral=True
204+
f"{player.display_name} was kicked from the game.", ephemeral=True
212205
)
213206

214207
async def dm_current_player_turn(self, lobby, channel_id: int) -> None:
@@ -266,10 +259,7 @@ async def run_afk_timer(
266259
game.draw_and_pass(player_id)
267260

268261
# update last move
269-
lobby.last_move = {
270-
"type": "draw",
271-
"player": player_id
272-
}
262+
lobby.last_move = {"type": "draw", "player": player_id}
273263

274264
channel = self.bot.get_channel(channel_id)
275265
if channel:

models/game_state.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Phase(Enum):
3131
PLAYING is when the game is being played and players can play cards. FINISHED is when the game
3232
has ended and a winner has been declared.
3333
"""
34+
3435
LOBBY = auto()
3536
PLAYING = auto()
3637
FINISHED = auto()
@@ -40,6 +41,7 @@ class Direction(Enum):
4041
"""
4142
The current direction of turn progression.
4243
"""
44+
4345
COUNTER_CLOCKWISE = auto()
4446
CLOCKWISE = auto()
4547

@@ -48,6 +50,7 @@ class GameError(Exception):
4850
"""
4951
Describes an error that has occurred with the game.
5052
"""
53+
5154
def __init__(self, msg: str, private: bool = False, title: str = ""):
5255
super().__init__(msg)
5356
self.private = private
@@ -59,6 +62,7 @@ class PlayResult:
5962
"""
6063
The result of a played card, containing information about its effects on the game.
6164
"""
65+
6266
# pylint: disable=too-many-instance-attributes
6367
played_by: int
6468
played_card: Card
@@ -78,6 +82,7 @@ class DrawResult:
7882
The result of drawing cards, containing information about who drew the cards and whose turn is
7983
next.
8084
"""
85+
8186
user_id: int
8287
drawn: list[Card]
8388
next_player: int
@@ -124,7 +129,7 @@ def _new_state(self) -> dict[str, Any]:
124129
"turn_index": 0, # index representing which users turn it is
125130
"turn_count": 0, # counter representing the current turn #
126131
"afk_deadline": None, # AFK timer deadline (UTC datetime)
127-
"uno_grace_until": 0.0, # timestamp when others may start catching
132+
"uno_grace_until": 0.0, # timestamp when others may start catching
128133
"uno_vulnerable": None, # user_id who has 1 card and can be caught
129134
"direction": Direction.CLOCKWISE,
130135
"winner": None,
@@ -551,7 +556,9 @@ def _now(self) -> float:
551556
return time.monotonic()
552557

553558
def _set_afk_deadline(self, seconds: int = 60) -> None:
554-
self.state["afk_deadline"] = datetime.now(timezone.utc) + timedelta(seconds=seconds)
559+
self.state["afk_deadline"] = datetime.now(timezone.utc) + timedelta(
560+
seconds=seconds
561+
)
555562

556563
def _clear_afk_deadline(self) -> None:
557564
self.state["afk_deadline"] = None

ui/game_ui.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ async def draw_card_and_pass(
116116
self.game_service.draw(interaction.channel_id, interaction.user.id)
117117

118118
# record draw as last move so the embed can show it
119-
self.lobby.last_move = {
120-
"type": "draw",
121-
"player": interaction.user.id
122-
}
119+
self.lobby.last_move = {"type": "draw", "player": interaction.user.id}
123120

124121
except GameError as e:
125122
embed = self._renderer.lobby_views.error_embed(

0 commit comments

Comments
 (0)