From a84554b0f147b39f0bcd6c0a65ad0e6b4f148a50 Mon Sep 17 00:00:00 2001 From: Nils Brinkmann Date: Thu, 31 Oct 2024 15:34:21 +0100 Subject: [PATCH] Fixed directly calling a potentially missing key in a dict Fixes #603 --- espn_api/basketball/player.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espn_api/basketball/player.py b/espn_api/basketball/player.py index 25c4cc8c..2182495e 100644 --- a/espn_api/basketball/player.py +++ b/espn_api/basketball/player.py @@ -42,7 +42,7 @@ def __init__(self, data, year, pro_team_schedule = None): applied_avg = round(split.get('appliedAverage', 0), 2) game = self.schedule.get(id, {}) self.stats[id] = dict(applied_total=applied_total, applied_avg=applied_avg, team=game.get('team', None), date=game.get('date', None)) - if split['stats']: + if split.get('stats'): if 'averageStats' in split.keys(): self.stats[id]['avg'] = {STATS_MAP.get(i, i): split['averageStats'][i] for i in split['averageStats'].keys() if STATS_MAP.get(i) != ''} self.stats[id]['total'] = {STATS_MAP.get(i, i): split['stats'][i] for i in split['stats'].keys() if STATS_MAP.get(i) != ''}