@@ -59,9 +59,7 @@ class InvalidCellOrderError(Exception): ...
5959class InvalidNumberOfUnfilledCellsError (Exception ): ...
6060
6161
62- @dataclass (frozen = True )
63- class AlreadyCompletedGameError (Exception ):
64- game_result : GameResult
62+ class AlreadyCompletedGameError (Exception ): ...
6563
6664
6765class 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 (),
0 commit comments