Skip to content

Commit c7c1481

Browse files
committed
style: format by ruff
1 parent 64d47d8 commit c7c1481

File tree

71 files changed

+708
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+708
-347
lines changed

src/ttt/application/game/common/ports/game_ai_gateway.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
class GameAiGateway(ABC):
88
@abstractmethod
99
async def next_move_cell_number_int(
10-
self, game: Game, ai_id: UUID, /,
10+
self,
11+
game: Game,
12+
ai_id: UUID,
13+
/,
1114
) -> int | None: ...

src/ttt/application/game/common/ports/game_views.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,67 @@ async def render_started_game_view_with_locations(
2424

2525
@abstractmethod
2626
async def render_no_game_view(
27-
self, user_location: UserLocation, /,
27+
self,
28+
user_location: UserLocation,
29+
/,
2830
) -> None: ...
2931

3032
@abstractmethod
3133
async def render_game_already_complteted_view(
32-
self, user_location: UserLocation, game: Game, /,
34+
self,
35+
user_location: UserLocation,
36+
game: Game,
37+
/,
3338
) -> None: ...
3439

3540
@abstractmethod
3641
async def render_not_current_user_view(
37-
self, user_location: UserLocation, game: Game, /,
42+
self,
43+
user_location: UserLocation,
44+
game: Game,
45+
/,
3846
) -> None: ...
3947

4048
@abstractmethod
4149
async def render_no_cell_view(
42-
self, user_location: UserLocation, game: Game, /,
50+
self,
51+
user_location: UserLocation,
52+
game: Game,
53+
/,
4354
) -> None: ...
4455

4556
@abstractmethod
4657
async def render_already_filled_cell_error(
47-
self, user_location: UserLocation, game: Game, /,
58+
self,
59+
user_location: UserLocation,
60+
game: Game,
61+
/,
4862
) -> None: ...
4963

5064
@abstractmethod
5165
async def render_user_already_in_game_views(
52-
self, locations: Sequence[UserLocation],
66+
self,
67+
locations: Sequence[UserLocation],
68+
/,
5369
) -> None: ...
5470

5571
@abstractmethod
5672
async def render_waiting_for_game_view(
57-
self, location: UserLocation,
73+
self,
74+
location: UserLocation,
75+
/,
5876
) -> None: ...
5977

6078
@abstractmethod
6179
async def render_double_waiting_for_game_view(
62-
self, location: UserLocation,
80+
self,
81+
location: UserLocation,
82+
/,
6383
) -> None: ...
6484

6585
@abstractmethod
6686
async def render_waiting_for_ai_type_to_start_game_with_ai_view(
67-
self, location: UserLocation,
87+
self,
88+
location: UserLocation,
89+
/,
6890
) -> None: ...

src/ttt/application/game/common/ports/games.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ class NoGameError(Exception): ...
99
class Games(ABC):
1010
@abstractmethod
1111
async def game_with_game_location(
12-
self, game_location_user_id: int, /,
12+
self,
13+
game_location_user_id: int,
14+
/,
1315
) -> Game | None: ...

src/ttt/application/game/common/ports/waiting_locations.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ class WaitingLocationsPush:
1313
class WaitingLocations(ABC):
1414
@abstractmethod
1515
async def push(
16-
self, location: UserLocation, /,
16+
self,
17+
location: UserLocation,
18+
/,
1719
) -> WaitingLocationsPush: ...
1820

1921
@abstractmethod
2022
async def push_many(
21-
self, locations: Sequence[UserLocation], /,
23+
self,
24+
locations: Sequence[UserLocation],
25+
/,
2226
) -> None: ...
2327

2428
@abstractmethod

src/ttt/application/game/game/cancel_game.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ async def __call__(self, location: UserLocation) -> None:
4444
game.cancel(location.user_id, game_result_id, tracking)
4545
except AlreadyCompletedGameError:
4646
await self.log.already_completed_game_to_cancel(
47-
game, location,
47+
game,
48+
location,
4849
)
4950
await self.game_views.render_game_already_complteted_view(
50-
location, game,
51+
location,
52+
game,
5153
)
5254
return
5355

5456
await self.log.game_cancelled(location, game)
5557

5658
await self.map_(tracking)
5759
await self.game_views.render_game_view_with_locations(
58-
locations, game,
60+
locations,
61+
game,
5962
)

src/ttt/application/game/game/make_move_in_game.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,48 @@ async def __call__(
6767
)
6868
except AlreadyCompletedGameError:
6969
await self.log.already_completed_game_to_make_move(
70-
game, location, cell_number_int,
70+
game,
71+
location,
72+
cell_number_int,
7173
)
7274
await self.game_views.render_game_already_complteted_view(
73-
location, game,
75+
location,
76+
game,
7477
)
7578
except NotCurrentPlayerError:
7679
await self.log.not_current_player_to_make_move(
77-
game, location, cell_number_int,
80+
game,
81+
location,
82+
cell_number_int,
7883
)
7984
await self.game_views.render_not_current_user_view(
80-
location, game,
85+
location,
86+
game,
8187
)
8288
except NoCellError:
8389
await self.log.no_cell_to_make_move(
84-
game, location, cell_number_int,
90+
game,
91+
location,
92+
cell_number_int,
8593
)
8694
await self.game_views.render_no_cell_view(location, game)
8795
except AlreadyFilledCellError:
8896
await self.log.already_filled_cell_to_make_move(
89-
game, location, cell_number_int,
97+
game,
98+
location,
99+
cell_number_int,
90100
)
91101
await self.game_views.render_already_filled_cell_error(
92-
location, game,
102+
location,
103+
game,
93104
)
94105
else:
95106
await self.log.user_move_maked(location, game, user_move)
96107

97108
if user_move.next_move_ai_id is not None:
98109
await self.game_views.render_game_view_with_locations(
99-
locations, game,
110+
locations,
111+
game,
100112
)
101113

102114
game_result_id = await self.uuids.random_uuid()
@@ -116,13 +128,16 @@ async def __call__(
116128
)
117129

118130
await self.log.ai_move_maked(
119-
location, game, ai_move,
131+
location,
132+
game,
133+
ai_move,
120134
)
121135

122136
if game.is_completed():
123137
await self.log.game_completed(location, game)
124138

125139
await self.map_(tracking)
126140
await self.game_views.render_game_view_with_locations(
127-
locations, game,
141+
locations,
142+
game,
128143
)

src/ttt/application/game/game/ports/game_log.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,66 @@ async def game_completed(
7878

7979
@abstractmethod
8080
async def user_already_in_game_to_start_game(
81-
self, user: User, location: UserLocation, /,
81+
self,
82+
user: User,
83+
location: UserLocation,
84+
/,
8285
) -> None: ...
8386

8487
@abstractmethod
8588
async def already_completed_game_to_make_move(
86-
self, game: Game, location: UserLocation, cell_number_int: int, /,
89+
self,
90+
game: Game,
91+
location: UserLocation,
92+
cell_number_int: int,
93+
/,
8794
) -> None: ...
8895

8996
@abstractmethod
9097
async def not_current_player_to_make_move(
91-
self, game: Game, location: UserLocation, cell_number_int: int, /,
98+
self,
99+
game: Game,
100+
location: UserLocation,
101+
cell_number_int: int,
102+
/,
92103
) -> None: ...
93104

94105
@abstractmethod
95106
async def no_cell_to_make_move(
96-
self, game: Game, location: UserLocation, cell_number_int: int, /,
107+
self,
108+
game: Game,
109+
location: UserLocation,
110+
cell_number_int: int,
111+
/,
97112
) -> None: ...
98113

99114
@abstractmethod
100115
async def already_filled_cell_to_make_move(
101-
self, game: Game, location: UserLocation, cell_number_int: int, /,
116+
self,
117+
game: Game,
118+
location: UserLocation,
119+
cell_number_int: int,
120+
/,
102121
) -> None: ...
103122

104123
@abstractmethod
105124
async def already_completed_game_to_cancel(
106-
self, game: Game, location: UserLocation, /,
125+
self,
126+
game: Game,
127+
location: UserLocation,
128+
/,
107129
) -> None: ...
108130

109131
@abstractmethod
110132
async def users_already_in_game_to_start_game_via_matchmaking_queue(
111-
self, locations_of_users_in_game: Sequence[UserLocation], /,
133+
self,
134+
locations_of_users_in_game: Sequence[UserLocation],
135+
/,
112136
) -> None: ...
113137

114138
@abstractmethod
115139
async def bad_attempt_to_start_game_via_matchmaking_queue(
116-
self, locations_of_users_not_in_game: Sequence[UserLocation], /,
140+
self,
141+
locations_of_users_not_in_game: Sequence[UserLocation],
142+
/,
117143
) -> None: ...

src/ttt/application/game/game/start_game.py

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,41 @@ async def __call__(self) -> None:
3535
user1, user2 = await self.users.users_with_ids(
3636
(user1_location.user_id, user2_location.user_id),
3737
)
38-
users_and_locations = tuple(zip(
39-
(user1, user2),
40-
(user1_location, user2_location),
41-
strict=True,
42-
))
43-
game_id, cell_id_matrix, user1_emoji, user2_emoji = (
44-
await gather(
45-
self.uuids.random_uuid(),
46-
self.uuids.random_uuid_matrix((3, 3)),
47-
self.emojis.random_emoji(),
48-
self.emojis.random_emoji(),
49-
)
38+
users_and_locations = tuple(
39+
zip(
40+
(user1, user2),
41+
(user1_location, user2_location),
42+
strict=True,
43+
),
44+
)
45+
(
46+
game_id,
47+
cell_id_matrix,
48+
user1_emoji,
49+
user2_emoji,
50+
) = await gather(
51+
self.uuids.random_uuid(),
52+
self.uuids.random_uuid_matrix((3, 3)),
53+
self.emojis.random_emoji(),
54+
self.emojis.random_emoji(),
5055
)
5156

5257
if user1 is None:
53-
await (
54-
self.user_views.render_user_is_not_registered_view(
55-
user1_location,
56-
)
58+
await self.user_views.render_user_is_not_registered_view(
59+
user1_location,
5760
)
5861
if user2 is None:
59-
await (
60-
self.user_views.render_user_is_not_registered_view(
61-
user2_location,
62-
)
62+
await self.user_views.render_user_is_not_registered_view(
63+
user2_location,
6364
)
6465
if user1 is None or user2 is None:
65-
await self.waiting_locations.push_many(tuple(
66-
location
67-
for user, location in users_and_locations
68-
if user is not None
69-
))
66+
await self.waiting_locations.push_many(
67+
tuple(
68+
location
69+
for user, location in users_and_locations
70+
if user is not None
71+
),
72+
)
7073
continue
7174

7275
tracking = Tracking()
@@ -123,8 +126,8 @@ async def __call__(self) -> None:
123126
user2_location.game(game.id),
124127
)
125128
await (
126-
self.game_views
127-
.render_started_game_view_with_locations(
128-
game_locations, game,
129+
self.game_views.render_started_game_view_with_locations(
130+
game_locations,
131+
game,
129132
)
130133
)

0 commit comments

Comments
 (0)