Clean Code: Python

Fix issues found by flake8-bugbear:

* Unused loop variables
* assert statements in non-test code
* mixing test code with production code
* mark one excessive test which takes ~10min to run
  as 'slow'
This commit is contained in:
Martin Thoma
2022-03-18 14:58:25 +01:00
parent f7deaba4a1
commit f52d9a0e54
27 changed files with 97 additions and 57 deletions

View File

@@ -209,7 +209,7 @@ def generate_ship_coordinates(ship):
coords = [(start_x, start_y)]
x_coord = start_x
y_coord = start_y
for i in range(ship_len):
for _ in range(ship_len):
x_coord = x_coord + d_x
y_coord = y_coord + d_y
coords.append((x_coord, y_coord))
@@ -356,7 +356,7 @@ def initialize_game():
for ship in SHIPS:
print(ship[0])
list = []
for i in range(ship[1]):
for _ in range(ship[1]):
x, y = input_coord()
list.append((x, y))
ship_coords.append(list)
@@ -443,7 +443,7 @@ def execute_turn(turn):
num_shots = num_player_shots
shots = []
for shot in range(num_shots):
for _shot in range(num_shots):
valid_shot = False
x = -1
y = -1