From 4919a130b3b8f5ba9c5143249e7701b0d36c637c Mon Sep 17 00:00:00 2001 From: Bart Feenstra Date: Fri, 21 Jun 2024 22:31:38 +0100 Subject: [PATCH] Remove the deprecated cache compatibility later (#1597) --- betty/app/__init__.py | 22 ++++------------------ betty/cache/__init__.py | 16 ---------------- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/betty/app/__init__.py b/betty/app/__init__.py index 11ec1461d..8d8953e12 100644 --- a/betty/app/__init__.py +++ b/betty/app/__init__.py @@ -28,7 +28,6 @@ ConfigurableExtension, ) from betty.asyncio import wait_to_thread -from betty.cache import Cache, FileCache from betty.cache.file import BinaryFileCache, PickledFileCache from betty.config import Configurable, FileBasedConfiguration from betty.fetch import Fetcher @@ -72,6 +71,7 @@ from betty.warnings import deprecate if TYPE_CHECKING: + from betty.cache import Cache from betty.dispatch import Dispatcher from types import TracebackType from collections.abc import AsyncIterator @@ -175,20 +175,6 @@ def dump(self) -> VoidableDump: return minimize({"locale": void_none(self.locale)}, True) -class _BackwardsCompatiblePickledFileCache(PickledFileCache[Any], FileCache): - """ - Provide a Backwards Compatible cache. - - .. deprecated:: 0.3.3 - This class is deprecated as of Betty 0.3.3, and will be removed in Betty 0.4.x. - """ - - @override - @property - def path(self) -> Path: - return self._path - - @final class App(Configurable[AppConfiguration]): """ @@ -240,7 +226,7 @@ def __init__( if cache_directory_path is None else cache_directory_path ) - self._cache: Cache[Any] & FileCache | None = None + self._cache: Cache[Any] | None = None self._binary_file_cache: BinaryFileCache | None = None self._process_pool: Executor | None = None @@ -660,12 +646,12 @@ def event_types(self) -> None: self._event_types = None @property - def cache(self) -> Cache[Any] & FileCache: + def cache(self) -> Cache[Any]: """ The cache. """ if self._cache is None: - self._cache = _BackwardsCompatiblePickledFileCache( + self._cache = PickledFileCache[Any]( self.localizer, self._cache_directory_path ) return self._cache diff --git a/betty/cache/__init__.py b/betty/cache/__init__.py index 140ceb3f6..b85118e80 100644 --- a/betty/cache/__init__.py +++ b/betty/cache/__init__.py @@ -7,12 +7,8 @@ from collections.abc import Awaitable, Callable from typing import Self, Generic, TypeAlias, AsyncContextManager, overload, Literal -import typing_extensions from typing_extensions import TypeVar -if typing_extensions.TYPE_CHECKING: - from pathlib import Path - _CacheItemValueT = TypeVar("_CacheItemValueT") _CacheItemValueCoT = TypeVar("_CacheItemValueCoT", covariant=True) @@ -125,15 +121,3 @@ async def clear(self) -> None: Clear all items from the cache. """ raise NotImplementedError - - -@typing_extensions.deprecated( - f"This class is deprecated as of Betty 0.3.3, and will be removed in Betty 0.4.x. It exists only for App.cache's backwards compatibility. Use {Cache} instead." -) -class FileCache: # noqa D101 - @property - def path(self) -> Path: # type: ignore[empty-body] # noqa D102 - pass - - async def clear(self) -> None: # noqa D102 - pass