From a50eb41282babff8628255d444168ddbf18afbc6 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Fri, 18 Apr 2025 14:07:59 -0500 Subject: [PATCH] Fix NoneType error by adding proper checks for current_game --- src/nhl_managers.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/nhl_managers.py b/src/nhl_managers.py index 324cffde..95fda70b 100644 --- a/src/nhl_managers.py +++ b/src/nhl_managers.py @@ -541,11 +541,16 @@ class NHLRecentManager(BaseNHLManager): for game in games: print(f" {game['away_abbr']} vs {game['home_abbr']}") - logging.info(f"[NHL] Rotating to recent game: {self.current_game['away_abbr']} vs {self.current_game['home_abbr']}") + if self.current_game: + logging.info(f"[NHL] Rotating to recent game: {self.current_game['away_abbr']} vs {self.current_game['home_abbr']}") + else: + logging.info("[NHL] No current game to display") else: logging.info("[NHL] No recent games found") + self.current_game = None else: logging.info("[NHL] No events found in the last few days") + self.current_game = None def display(self, force_clear: bool = False): """Display recent game information.""" @@ -667,9 +672,13 @@ class NHLUpcomingManager(BaseNHLManager): for game in games: print(f" {game['away_abbr']} vs {game['home_abbr']}") - logging.info(f"[NHL] Rotating to upcoming game: {self.current_game['away_abbr']} vs {self.current_game['home_abbr']}") + if self.current_game: + logging.info(f"[NHL] Rotating to upcoming game: {self.current_game['away_abbr']} vs {self.current_game['home_abbr']}") + else: + logging.info("[NHL] No current game to display") else: logging.info("[NHL] No upcoming games found") + self.current_game = None def display(self, force_clear: bool = False): """Display upcoming game information."""