Selaa lähdekoodia

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
Masen Furer 4 kuukautta sitten
vanhempi
säilyke
59b3aaca42
1 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 10 1
      reflex/vars/base.py

+ 10 - 1
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.")