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. 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.