Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing lru_cache with cache, post-3.8 #2912

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading