From e3b65588a255249e84b7e16cc5f1cb256634888e Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Fri, 15 Aug 2025 09:38:23 -0500 Subject: [PATCH] support older versions of python not having the Union import --- src/display_controller.py | 4 ++-- src/music_manager.py | 3 ++- src/weather_icons.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/display_controller.py b/src/display_controller.py index 9b67495a..2cf7de13 100644 --- a/src/display_controller.py +++ b/src/display_controller.py @@ -627,11 +627,11 @@ class DisplayController: if self.ncaam_basketball_recent: self.ncaam_basketball_recent.update() if self.ncaam_basketball_upcoming: self.ncaam_basketball_upcoming.update() - def _check_live_games(self) -> tuple[bool, str]: + def _check_live_games(self) -> tuple: """ Check if there are any live games available. Returns: - tuple[bool, str]: (has_live_games, sport_type) + tuple: (has_live_games, sport_type) sport_type will be 'nhl', 'nba', 'mlb', 'milb', 'soccer' or None """ # Only include sports that are enabled in config diff --git a/src/music_manager.py b/src/music_manager.py index 9465f2f1..ab5a4929 100644 --- a/src/music_manager.py +++ b/src/music_manager.py @@ -6,6 +6,7 @@ import json import os from io import BytesIO import requests +from typing import Union from PIL import Image, ImageEnhance import queue # Added import @@ -305,7 +306,7 @@ class MusicManager: except Exception as e: logger.error(f"Error executing DisplayController update callback from YTM direct update: {e}") - def _fetch_and_resize_image(self, url: str, target_size: tuple[int, int]) -> Image.Image | None: + def _fetch_and_resize_image(self, url: str, target_size: tuple) -> Union[Image.Image, None]: """Fetches an image from a URL, resizes it, and returns a PIL Image object.""" if not url: return None diff --git a/src/weather_icons.py b/src/weather_icons.py index d0c8c256..7fcc12d6 100644 --- a/src/weather_icons.py +++ b/src/weather_icons.py @@ -1,4 +1,5 @@ import os +from typing import Union from PIL import Image, ImageDraw # math is no longer needed for drawing, remove if not used elsewhere # import math @@ -62,7 +63,7 @@ class WeatherIcons: return filename @staticmethod - def load_weather_icon(icon_code: str, size: int = DEFAULT_SIZE) -> Image.Image | None: + def load_weather_icon(icon_code: str, size: int = DEFAULT_SIZE) -> Union[Image.Image, None]: """Loads, converts, and resizes the appropriate weather icon based on the OWM code. Returns None on failure.""" filename = WeatherIcons._get_icon_filename(icon_code) icon_path = os.path.join(WeatherIcons.ICON_DIR, filename)