Skip to content

Commit

Permalink
fix B909 mutation to loop iterable during iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
TabulateJarl8 committed Sep 10, 2024
1 parent a6aae03 commit 0330bc0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions vapor/api_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,15 @@ async def parse_steam_user_games(
# remove all of the games that we used that were already cached
# this ensures that the timestamps of those games don't get updated
game_ratings_copy = game_ratings.copy()
for game in game_ratings_copy:
if cache.get_game_data(game.app_id) is not None:
game_ratings_copy.remove(game)
games_to_remove: List[Game] = [
game
for game in game_ratings_copy
if cache.get_game_data(game.app_id) is not None
]

# we do this in a seperate loop so that we're not mutating the iterable during iteration
for game in games_to_remove:
game_ratings_copy.remove(game)

# update the game cache
cache.update_cache(game_list=game_ratings)
Expand Down

0 comments on commit 0330bc0

Please sign in to comment.