From df76217b641e589468612cb4570bb7fbcb6ab195 Mon Sep 17 00:00:00 2001 From: Charles Whittington Date: Tue, 15 Oct 2024 18:11:11 -0400 Subject: [PATCH 1/2] Replaced lru_cache with cache, post-3.8 --- core/src/toga/images.py | 4 ++-- core/src/toga/platform.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/toga/images.py b/core/src/toga/images.py index 57471e96c3..0ae0df8efd 100644 --- a/core/src/toga/images.py +++ b/core/src/toga/images.py @@ -4,7 +4,7 @@ import os import sys import warnings -from functools import lru_cache +from functools import cache from pathlib import Path from typing import TYPE_CHECKING, Any, Protocol, TypeVar from warnings import warn @@ -155,7 +155,7 @@ def __init__( raise TypeError("Unsupported source type for Image") @classmethod - @lru_cache(maxsize=None) + @cache def _converters(cls) -> list[ImageConverter]: """Return list of registered image plugin converters. Only loaded once.""" converters = [] diff --git a/core/src/toga/platform.py b/core/src/toga/platform.py index 8bb3172acf..91ac859016 100644 --- a/core/src/toga/platform.py +++ b/core/src/toga/platform.py @@ -3,7 +3,7 @@ import importlib import os import sys -from functools import lru_cache +from functools import cache from types import ModuleType if sys.version_info >= (3, 10): # pragma: no-cover-if-lt-py310 @@ -51,7 +51,7 @@ def find_backends(): return sorted(set(entry_points(group="toga.backends"))) -@lru_cache(maxsize=1) +@cache def get_platform_factory() -> ModuleType: """Determine the current host platform and import the platform factory. From 389547a4c270bc1fd0da1559b1c646c5f2c3de64 Mon Sep 17 00:00:00 2001 From: Charles Whittington Date: Tue, 15 Oct 2024 18:19:16 -0400 Subject: [PATCH 2/2] Added changenote --- changes/2912.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/2912.misc.rst diff --git a/changes/2912.misc.rst b/changes/2912.misc.rst new file mode 100644 index 0000000000..8e509b576b --- /dev/null +++ b/changes/2912.misc.rst @@ -0,0 +1 @@ +Use of functools.lru_cache has been replaced with functools.cache, now that Python 3.8 is no longer supported.