support older versions of python not having the Union import

This commit is contained in:
ChuckBuilds
2025-08-15 09:38:23 -05:00
parent f13e9306c9
commit e3b65588a2
3 changed files with 6 additions and 4 deletions

View File

@@ -627,11 +627,11 @@ class DisplayController:
if self.ncaam_basketball_recent: self.ncaam_basketball_recent.update() if self.ncaam_basketball_recent: self.ncaam_basketball_recent.update()
if self.ncaam_basketball_upcoming: self.ncaam_basketball_upcoming.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. Check if there are any live games available.
Returns: 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 sport_type will be 'nhl', 'nba', 'mlb', 'milb', 'soccer' or None
""" """
# Only include sports that are enabled in config # Only include sports that are enabled in config

View File

@@ -6,6 +6,7 @@ import json
import os import os
from io import BytesIO from io import BytesIO
import requests import requests
from typing import Union
from PIL import Image, ImageEnhance from PIL import Image, ImageEnhance
import queue # Added import import queue # Added import
@@ -305,7 +306,7 @@ class MusicManager:
except Exception as e: except Exception as e:
logger.error(f"Error executing DisplayController update callback from YTM direct update: {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.""" """Fetches an image from a URL, resizes it, and returns a PIL Image object."""
if not url: if not url:
return None return None

View File

@@ -1,4 +1,5 @@
import os import os
from typing import Union
from PIL import Image, ImageDraw from PIL import Image, ImageDraw
# math is no longer needed for drawing, remove if not used elsewhere # math is no longer needed for drawing, remove if not used elsewhere
# import math # import math
@@ -62,7 +63,7 @@ class WeatherIcons:
return filename return filename
@staticmethod @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.""" """Loads, converts, and resizes the appropriate weather icon based on the OWM code. Returns None on failure."""
filename = WeatherIcons._get_icon_filename(icon_code) filename = WeatherIcons._get_icon_filename(icon_code)
icon_path = os.path.join(WeatherIcons.ICON_DIR, filename) icon_path = os.path.join(WeatherIcons.ICON_DIR, filename)