Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Refactor type hint for font cache and function return type in python_highlights.py
Magnus Müller198f343c6abf
diff --git a/browser_use/browser/python_highlights.py b/browser_use/browser/python_highlights.pyindex 6917c9996..c72ee9652 100644--- a/browser_use/browser/python_highlights.py+++ b/browser_use/browser/python_highlights.py@@ -10,7 +10,6 @@ import gcimport ioimport loggingimport os-from typing import Optionalfrom PIL import Image, ImageDraw, ImageFont@@ -21,7 +20,7 @@ from browser_use.utils import time_execution_asynclogger = logging.getLogger(__name__)# Font cache to prevent repeated font loading and reduce memory usage-_FONT_CACHE: dict[tuple[str, int], Optional[ImageFont.FreeTypeFont]] = {}+_FONT_CACHE: dict[tuple[str, int], ImageFont.FreeTypeFont | None] = {}# Cross-platform font paths_FONT_PATHS = [@@ -35,7 +34,7 @@ _FONT_PATHS = []-def get_cross_platform_font(font_size: int) -> Optional[ImageFont.FreeTypeFont]:+def get_cross_platform_font(font_size: int) -> ImageFont.FreeTypeFont | None:"""Get a cross-platform compatible font with caching to prevent memory leaks.Args: