Skip to content

Commit e103c20

Browse files
committed
fix: fix linter errors
1 parent 5fee602 commit e103c20

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/ttt/entities/core/game/game.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ class InvalidCellOrderError(Exception): ...
5959
class InvalidNumberOfUnfilledCellsError(Exception): ...
6060

6161

62-
@dataclass(frozen=True)
63-
class AlreadyCompletedGameError(Exception):
64-
game_result: GameResult
62+
class AlreadyCompletedGameError(Exception): ...
6563

6664

6765
class NoCellError(Exception): ...
@@ -129,9 +127,9 @@ def cancel(
129127
:raises ttt.entities.core.game.game.NotPlayerError:
130128
"""
131129

132-
if self.result is not None:
133-
raise AlreadyCompletedGameError(self.result)
134-
130+
self.result = cast(
131+
GameResult, not_none(self.result, AlreadyCompletedGameError),
132+
)
135133
canceler = not_none(self._player(player_id), else_=NotPlayerError)
136134

137135
self.player1.leave_game(tracking)
@@ -160,13 +158,9 @@ def make_move(
160158
:raises ttt.entities.core.game.cell.AlreadyFilledCellError:
161159
"""
162160

163-
current_player = self._current_player()
164-
165-
if current_player is None:
166-
raise AlreadyCompletedGameError(
167-
cast(GameResult, not_none(self.result)),
168-
)
169-
161+
current_player = not_none(
162+
self._current_player(), AlreadyCompletedGameError,
163+
)
170164
assert_(
171165
player_id in {self.player1.id, self.player2.id},
172166
else_=NotPlayerError(),

src/ttt/infrastructure/adapters/players.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,12 @@ async def players_with_ids( # type: ignore[overload-cannot-match]
3535
async def players_with_ids(
3636
self, ids: Sequence[int],
3737
) -> tuple[Player, ...]:
38-
return tuple(await gather(*map(self.player_with_id, ids)))
38+
return tuple(await gather(*map(self._player_with_id, ids)))
39+
40+
async def _player_with_id(self, id_: int, /) -> Player:
41+
table_player = await self._session.get(TablePlayer, id_)
42+
43+
if table_player is None:
44+
raise NoPlayerWithIDError(id_)
45+
46+
return table_player.entity()

0 commit comments

Comments
 (0)