diff --git a/changelog.d/70.removed.md b/changelog.d/70.removed.md new file mode 100644 index 0000000..044b724 --- /dev/null +++ b/changelog.d/70.removed.md @@ -0,0 +1,3 @@ +**`BackendProxy.get_backend()` and `BackendProxy.set_backend()` are removed.** +They had emitted a `DeprecationWarning` since 0.3.0. Call `BackendProxy.get()` +and `BackendProxy.set(backend)` instead. diff --git a/fastapi_cachex/proxy.py b/fastapi_cachex/proxy.py index 7cde895..6dbcc37 100644 --- a/fastapi_cachex/proxy.py +++ b/fastapi_cachex/proxy.py @@ -3,7 +3,6 @@ from __future__ import annotations import threading -import warnings from logging import getLogger from typing import TYPE_CHECKING from typing import ClassVar @@ -110,42 +109,6 @@ class BackendProxy(ProxyBase[BaseCacheBackend]): _not_set_error = BackendNotFoundError - @staticmethod - def get_backend() -> BaseCacheBackend: - """Get the current backend instance. - - .. deprecated:: 0.3.0 - Use :meth:`get` instead. Will be removed in version 0.4.0. - - Returns: - The current backend instance - """ - warnings.warn( - "get_backend() is deprecated, use get() instead. " - "Will be removed in version 0.4.0.", - DeprecationWarning, - stacklevel=2, - ) - return BackendProxy.get() - - @staticmethod - def set_backend(backend: BaseCacheBackend | None) -> None: - """Set the backend instance. - - .. deprecated:: 0.3.0 - Use :meth:`set` instead. Will be removed in version 0.4.0. - - Args: - backend: The backend instance to set, or None to clear - """ - warnings.warn( - "set_backend() is deprecated, use set() instead. " - "Will be removed in version 0.4.0.", - DeprecationWarning, - stacklevel=2, - ) - BackendProxy.set(backend) - def get_backend_or_fallback() -> BaseCacheBackend: """Return the configured backend, registering a `MemoryBackend` if none is. diff --git a/tests/test_proxybackend.py b/tests/test_proxybackend.py index 40d6c86..d72c14e 100644 --- a/tests/test_proxybackend.py +++ b/tests/test_proxybackend.py @@ -117,31 +117,6 @@ def test_backend_proxy_cannot_be_instantiated(): BackendProxy() -def test_get_backend_alias_warns_and_delegates(): - """The 0.3.0 deprecation shims stay callable until 0.4.0 removes them.""" - backend = MemoryBackend() - BackendProxy.set(backend) - - with pytest.warns(DeprecationWarning, match="get_backend\\(\\) is deprecated"): - assert BackendProxy.get_backend() is backend - - -def test_set_backend_alias_warns_and_delegates(): - """Same for the setter, including clearing with `None`.""" - backend = MemoryBackend() - - with pytest.warns(DeprecationWarning, match="set_backend\\(\\) is deprecated"): - BackendProxy.set_backend(backend) - - assert BackendProxy.get() is backend - - with pytest.warns(DeprecationWarning, match="set_backend\\(\\) is deprecated"): - BackendProxy.set_backend(None) - - with pytest.raises(BackendNotFoundError): - BackendProxy.get() - - @pytest.mark.parametrize( "proxy", [CacheManagerProxy, SessionManagerProxy, StateManagerProxy] )