Skip to content

Commit 0330bc0

Browse files
committed
fix B909 mutation to loop iterable during iteration
1 parent a6aae03 commit 0330bc0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

vapor/api_interface.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,15 @@ async def parse_steam_user_games(
252252
# remove all of the games that we used that were already cached
253253
# this ensures that the timestamps of those games don't get updated
254254
game_ratings_copy = game_ratings.copy()
255-
for game in game_ratings_copy:
256-
if cache.get_game_data(game.app_id) is not None:
257-
game_ratings_copy.remove(game)
255+
games_to_remove: List[Game] = [
256+
game
257+
for game in game_ratings_copy
258+
if cache.get_game_data(game.app_id) is not None
259+
]
260+
261+
# we do this in a seperate loop so that we're not mutating the iterable during iteration
262+
for game in games_to_remove:
263+
game_ratings_copy.remove(game)
258264

259265
# update the game cache
260266
cache.update_cache(game_list=game_ratings)

0 commit comments

Comments
 (0)