From 59b3aaca426a817c963a2de8a9ab8037a4d40ed7 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Mon, 6 Jan 2025 11:17:03 -0800 Subject: [PATCH] Add deprecation message for non-cached var (#4591) DeprecationWarning: Default non-cached rx.var has been deprecated in version 0.6.8 the default value will be `@rx.var(cache=True)` in a future release. To retain uncached var, explicitly pass `@rx.var(cache=False)`. It will be completely removed in 0.7.0 --- reflex/vars/base.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/reflex/vars/base.py b/reflex/vars/base.py index 094a478c8..31c5f2e94 100644 --- a/reflex/vars/base.py +++ b/reflex/vars/base.py @@ -2276,7 +2276,7 @@ def computed_var( def computed_var( fget: Callable[[BASE_STATE], Any] | None = None, initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, + cache: Optional[bool] = None, deps: Optional[List[Union[str, Var]]] = None, auto_deps: bool = True, interval: Optional[Union[datetime.timedelta, int]] = None, @@ -2302,6 +2302,15 @@ def computed_var( ValueError: If caching is disabled and an update interval is set. VarDependencyError: If user supplies dependencies without caching. """ + if cache is None: + cache = False + console.deprecate( + "Default non-cached rx.var", + "the default value will be `@rx.var(cache=True)` in a future release. " + "To retain uncached var, explicitly pass `@rx.var(cache=False)`", + deprecation_version="0.6.8", + removal_version="0.7.0", + ) if cache is False and interval is not None: raise ValueError("Cannot set update interval without caching.")