Skip to content

Commit

Permalink
Remove the deprecated cache compatibility later (#1597)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra authored Jun 21, 2024
1 parent 1b7fa3d commit 4919a13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 34 deletions.
22 changes: 4 additions & 18 deletions betty/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]):
"""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions betty/cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 4919a13

Please sign in to comment.