Skip to content

Commit

Permalink
Merge pull request #2912 from HalfWhitt/remove-lru-cache
Browse files Browse the repository at this point in the history
Replacing lru_cache with cache, post-3.8
  • Loading branch information
freakboy3742 authored Oct 15, 2024
2 parents 19e0469 + 389547a commit a1dfaec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/2912.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use of functools.lru_cache has been replaced with functools.cache, now that Python 3.8 is no longer supported.
4 changes: 2 additions & 2 deletions core/src/toga/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions core/src/toga/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a1dfaec

Please sign in to comment.