Skip to content

Commit 9dfa22f

Browse files
Merge pull request #939 from bwignall/fix_flake8_errors
Fix flake8 errors for Python code
2 parents 6f10b8f + 888f4a4 commit 9dfa22f

File tree

10 files changed

+33
-33
lines changed

10 files changed

+33
-33
lines changed

03_Animal/python/animal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def main() -> None:
131131
# Main loop of game
132132
print_intro()
133133
while (
134-
keep_playing := parse_input(
134+
parse_input(
135135
"Are you thinking of an animal? ", True, root
136136
)
137137
== "y"

07_Basketball/python/basketball.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def dartmouth_jump_shot(self) -> None:
139139
else:
140140
print("Shot is off target.")
141141
if self.defense / 6 * random.random() > 0.45:
142-
print(f"Rebound to {self.opponent}" + "\n")
142+
print(f"Rebound to {self.opponent}\n")
143143
self.opponent_ball()
144144
else:
145145
print("Dartmouth controls the rebound.")
@@ -185,7 +185,7 @@ def dartmouth_non_jump_shot(self) -> None:
185185
if 7 / self.defense * random.random() > 0.925:
186186
print("Charging foul. Dartmouth loses the ball.\n")
187187
else:
188-
print(f"Shot blocked. {self.opponent}" + "'s ball.\n")
188+
print(f"Shot blocked. {self.opponent}'s ball.\n")
189189
else:
190190
self.foul_shots(1)
191191
self.opponent_ball()
@@ -270,7 +270,7 @@ def opponent_jumpshot(self) -> None:
270270
or self.defense != 6
271271
and random.random() <= 0.5
272272
):
273-
print(f"Pass back to {self.opponent}" + " guard.\n")
273+
print(f"Pass back to {self.opponent} guard.\n")
274274
self.opponent_ball()
275275
elif self.defense == 6 and random.random() > 0.75:
276276
print("Ball stolen. Easy lay up for Dartmouth.")
@@ -310,14 +310,14 @@ def opponent_non_jumpshot(self) -> None:
310310
and random.random() <= 0.75
311311
and random.random() <= 0.5
312312
):
313-
print(f"Pass back to {self.opponent}" + " guard.\n")
313+
print(f"Pass back to {self.opponent} guard.\n")
314314
self.opponent_ball()
315315
elif self.defense == 6 and random.random() > 0.75:
316316
print("Ball stolen. Easy lay up for Dartmouth.")
317317
self.add_points(1, 2)
318318
self.opponent_ball()
319319
else:
320-
print(f"Pass back to {self.opponent}" + " guard\n")
320+
print(f"Pass back to {self.opponent} guard\n")
321321
self.opponent_ball()
322322
else:
323323
print("Dartmouth controls the rebound.\n")

17_Bullfight/python/bullfight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def determine_player_kills(
2929
print(f"THE {player_type}{plural_form} DID A {job_qualities[job_quality]} JOB.")
3030
if job_quality >= 4:
3131
if job_quality == 5:
32-
if player_was_killed := random.choice([True, False]):
32+
if random.choice([True, False]):
3333
print(f"ONE OF THE {player_type}{plural_form} WAS KILLED.")
3434
else:
3535
if player_type != "TOREAD":

49_Hockey/python/hockey.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def print_header() -> None:
127127

128128

129129
def instructions() -> None:
130-
if wants_it := ask_binary(
130+
if ask_binary(
131131
"WOULD YOU LIKE THE INSTRUCTIONS? ", "ANSWER YES OR NO!!"
132132
):
133133
print()
@@ -229,7 +229,7 @@ def team2_action(
229229
z1 = 3
230230
elif pass_value == 2:
231231
print("IT'S A ' 3 ON 2 '!\n")
232-
print(f"ONLY {team_a.players[3]} AND {team_a.players[4]}" + " ARE BACK.\n")
232+
print(f"ONLY {team_a.players[3]} AND {team_a.players[4]} ARE BACK.\n")
233233
print(
234234
team_b.players[player_index[j - 2]]
235235
+ " GIVES OFF TO "
@@ -374,7 +374,7 @@ def handle_hit(
374374
else:
375375
print(f"{team_b.name}: {team_b.score}\t{team_a.name}: {team_a.score}\n")
376376
team = team_a if controlling_team == 1 else team_b
377-
print(f"GOAL SCORED BY: {team.players[goal_player]}" + "\n")
377+
print(f"GOAL SCORED BY: {team.players[goal_player]}\n")
378378
if goal_assistant1 != 0:
379379
if goal_assistant2 != 0:
380380
print(
@@ -402,16 +402,16 @@ def handle_miss(
402402
saving_player = randint(1, 7)
403403
if controlling_team == 1:
404404
if saving_player == 1:
405-
print(f"KICK SAVE AND A BEAUTY BY {team_b.players[5]}" + "\n")
406-
print(f"CLEARED OUT BY {team_b.players[3]}" + "\n")
405+
print(f"KICK SAVE AND A BEAUTY BY {team_b.players[5]}\n")
406+
print(f"CLEARED OUT BY {team_b.players[3]}\n")
407407
remaining_time -= 1
408408
return ("continue", remaining_time)
409409
if saving_player == 2:
410-
print(f"WHAT A SPECTACULAR GLOVE SAVE BY {team_b.players[5]}" + "\n")
411-
print(f"AND {team_b.players[5]}" + " GOLFS IT INTO THE CROWD\n")
410+
print(f"WHAT A SPECTACULAR GLOVE SAVE BY {team_b.players[5]}\n")
411+
print(f"AND {team_b.players[5]} GOLFS IT INTO THE CROWD\n")
412412
return ("break", remaining_time)
413413
if saving_player == 3:
414-
print(f"SKATE SAVE ON A LOW STEAMER BY {team_b.players[5]}" + "\n")
414+
print(f"SKATE SAVE ON A LOW STEAMER BY {team_b.players[5]}\n")
415415
remaining_time -= 1
416416
return ("continue", remaining_time)
417417
if saving_player == 4:
@@ -447,20 +447,20 @@ def handle_miss(
447447
print("ON THE LOOSE PUCK!\n")
448448
return ("break", remaining_time)
449449
if saving_player == 3:
450-
print(f"SKATE SAVE BY {team_a.players[5]}" + "\n")
450+
print(f"SKATE SAVE BY {team_a.players[5]}\n")
451451
print(team_a.players[5] + " WHACKS THE LOOSE PUCK INTO THE STANDS\n")
452452
return ("break", remaining_time)
453453
if saving_player == 4:
454-
print(f"STICK SAVE BY {team_a.players[5]}" + " AND HE CLEARS IT OUT HIMSELF\n")
454+
print(f"STICK SAVE BY {team_a.players[5]} AND HE CLEARS IT OUT HIMSELF\n")
455455
remaining_time -= 1
456456
return ("continue", remaining_time)
457457
if saving_player == 5:
458-
print(f"KICKED OUT BY {team_a.players[5]}" + "\n")
458+
print(f"KICKED OUT BY {team_a.players[5]}\n")
459459
print("AND IT REBOUNDS ALL THE WAY TO CENTER ICE\n")
460460
remaining_time -= 1
461461
return ("continue", remaining_time)
462462
if saving_player == 6:
463-
print(f"GLOVE SAVE {team_a.players[5]}" + " AND HE HANGS ON\n")
463+
print(f"GLOVE SAVE {team_a.players[5]} AND HE HANGS ON\n")
464464
return ("break", remaining_time)
465465
return ("continue", remaining_time)
466466

59_Lunar_LEM_Rocket/python/lunar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def run_simulation() -> None:
324324
return
325325

326326
if capsule.velocity > 0 and new_state.velocity < 0:
327-
if landed := handle_flyaway(sim_clock, capsule):
327+
if handle_flyaway(sim_clock, capsule):
328328
process_final_tick(delta_t, sim_clock, capsule)
329329
return
330330

64_Nicomachus/python/nicomachus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def play_game() -> None:
4343

4444
print(f"YOUR NUMBER WAS {d}, RIGHT?")
4545

46-
if response := get_yes_or_no():
46+
if get_yes_or_no():
4747
print("HOW ABOUT THAT!!")
4848
else:
4949
print("I FEEL YOUR ARITHMETIC IS IN ERROR.")

65_Nim/python/Traditional_NIM.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ def main() -> None:
7878

7979
# Start game loop
8080
input("\nPress Enter to start the Game:\n")
81-
end = False
81+
8282
while True:
8383
game.print_pegs()
8484

8585
# Players Move
8686
command = input("\nYOUR MOVE - Number of PILE, Number of Object? ")
8787
game.remove_pegs(command)
88-
if end := game.check_for_win():
88+
if game.check_for_win():
8989
print("\nPlayer Wins the Game, Congratulations!!")
9090
input("\nPress any key to exit")
9191
break
@@ -96,7 +96,7 @@ def main() -> None:
9696
f"\nA.I MOVE - A.I Removed {ai_command[1]} pegs from Pile {ai_command[0]}"
9797
)
9898
game.remove_pegs(f"{str(ai_command[0])},{str(ai_command[1])}")
99-
if end := game.check_for_win():
99+
if game.check_for_win():
100100
print("\nComputer Wins the Game, Better Luck Next Time\n")
101101
input("Press any key to exit")
102102
break

69_Pizza/python/pizza.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def main() -> None:
155155

156156
player_name = print_instructions()
157157

158-
if more_directions := yes_no_prompt("DO YOU NEED MORE DIRECTIONS?"):
158+
if yes_no_prompt("DO YOU NEED MORE DIRECTIONS?"):
159159
print_more_directions(player_name)
160160

161161
understand = yes_no_prompt("UNDERSTAND?")

72_Queen/python/queen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ def num_to_loc(num: int) -> Tuple[int, int]:
117117
)
118118

119119
# These are the places that the computer will always try to move into.
120-
COMPUTER_PREF_MOVES: Final[
121-
FrozenSet[Tuple[int, int]]
122-
] = COMPUTER_SAFE_SPOTS | frozenset([WIN_LOC])
120+
COMPUTER_PREF_MOVES: Final[FrozenSet[Tuple[int, int]]] = (
121+
COMPUTER_SAFE_SPOTS | frozenset([WIN_LOC])
122+
)
123123

124124
# These are the locations (not including the win location) from which either player can
125125
# force a win (but the computer will always choose one of the COMPUTER_PREF_MOVES).
@@ -171,10 +171,10 @@ def get_move(current_loc: Optional[Tuple[int, int]]) -> Tuple[int, int]:
171171
"WHERE WOULD YOU LIKE TO START? "
172172
)
173173
elif (
174-
(new_row == row and new_col < col) # move left
175-
or (new_col == col and new_row > row) # move down
176-
or (new_row - row == col - new_col) # move diag left and down
177-
) and (not FIX_BOARD_BUG or (new_col >= 0 and new_row < 8)):
174+
(new_row == row and new_col < col) # move left
175+
or (new_col == col and new_row > row) # move down
176+
or (new_row - row == col - new_col) # move diag left and down
177+
) and (not FIX_BOARD_BUG or (new_col >= 0 and new_row < 8)):
178178
return new_row, new_col
179179
else:
180180
prompt = "Y O U C H E A T . . . TRY AGAIN? "

89_Tic-Tac-Toe/python/TicTacToe_Hard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def display(game: TicTacToe) -> None:
171171
if game.board[i][game.dim_sz - 1] == "blur":
172172
line1 = line1 + " \n"
173173
else:
174-
line1 = f"{line1} {game.board[i][game.dim_sz - 1]}" + " \n"
174+
line1 = f"{line1} {game.board[i][game.dim_sz - 1]} \n"
175175
print(line1, "\n\n")
176176

177177

0 commit comments

Comments
 (0)