Compare commits

...

5 Commits
main ... v0.5.6

Author SHA1 Message Date
Masen Furer
a115b3f3e6
pyproject.toml: bump to 0.5.6 (#3635) 2024-07-08 17:32:08 -07:00
Masen Furer
e148f19555
[REF-3157] Avoid SQLModel metaclass conflict (#3610)
Ensure that reflex.utils.compat is loaded whenever `reflex` itself is imported
to try and avoid the sqlmodel metaclass conflict error that arises when
sqlmodel is imported first with pydantic v2, but reflex Model inherits from
rx.Base which is based on pydantic v1.

Fix #3515
2024-07-08 11:43:16 -07:00
Masen Furer
270efb9f1b
[REF-3220] Fix rx.cancel_upload EventSpec (#3608)
The formatting of the upload ID had extra single quotes that were not needed.
Now that `_var_name_unwrapped` is used, any `str`-like Vars will automatically
be formatted with backticks
2024-07-08 11:43:16 -07:00
Masen Furer
d067fe9bb9
Update links to /docs/library/dynamic-rendering/foreach/ (#3609) 2024-07-08 11:43:15 -07:00
benedikt-bartscher
72b0737544
do not get_config in global scope (#3597)
* do not get_config in global scope

* ruff fixes

* pydantic v1 compatibility
2024-07-08 11:43:15 -07:00
6 changed files with 35 additions and 8 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "reflex"
version = "0.5.5"
version = "0.5.6"
description = "Web apps in pure Python."
license = "Apache-2.0"
authors = [

View File

@ -84,12 +84,18 @@ In the example above, you will be able to do `rx.list`
from __future__ import annotations
from reflex.utils import lazy_loader
from reflex.utils import (
compat, # for side-effects
lazy_loader,
)
# import this here explicitly to avoid returning the page module since page attr has the
# same name as page module(page.py)
from .page import page as page
# Remove the `compat` name from the namespace, it was imported for side-effects only.
del compat
RADIX_THEMES_MAPPING: dict = {
"components.radix.themes.base": ["color_mode", "theme", "theme_panel"],
"components.radix.themes.color_mode": ["color_mode"],

View File

@ -3,6 +3,8 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from reflex.utils import compat
from . import admin as admin
from . import app as app
from . import base as base
@ -190,6 +192,7 @@ from .utils.serializers import serializer as serializer
from .vars import Var as Var
from .vars import cached_var as cached_var
del compat
RADIX_THEMES_MAPPING: dict
RADIX_THEMES_COMPONENTS_MAPPING: dict
RADIX_THEMES_LAYOUT_MAPPING: dict

View File

@ -66,7 +66,7 @@ class Foreach(Component):
raise ForeachVarError(
f"Could not foreach over var `{iterable._var_full_name}` of type Any. "
"(If you are trying to foreach over a state var, add a type annotation to the var). "
"See https://reflex.dev/docs/library/layout/foreach/"
"See https://reflex.dev/docs/library/dynamic-rendering/foreach/"
)
if (
@ -95,7 +95,8 @@ class Foreach(Component):
if len(params) == 0 or len(params) > 2:
raise ForeachRenderError(
"Expected 1 or 2 parameters in foreach render function, got "
f"{[p.name for p in params]}. See https://reflex.dev/docs/library/layout/foreach/"
f"{[p.name for p in params]}. See "
"https://reflex.dev/docs/library/dynamic-rendering/foreach/"
)
if len(params) >= 1:

View File

@ -107,7 +107,7 @@ def cancel_upload(upload_id: str) -> EventSpec:
An event spec that cancels the upload when triggered.
"""
return call_script(
f"upload_controllers[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped!r}]?.abort()"
f"upload_controllers[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped}]?.abort()"
)

View File

@ -61,7 +61,6 @@ if TYPE_CHECKING:
Delta = Dict[str, Any]
var = computed_var
config = get_config()
# If the state is this large, it's considered a performance issue.
@ -2319,6 +2318,24 @@ def _dill_reduce_state(pickler, obj):
dill.Pickler.dispatch[type](pickler, obj)
def _default_lock_expiration() -> int:
"""Get the default lock expiration time.
Returns:
The default lock expiration time.
"""
return get_config().redis_lock_expiration
def _default_token_expiration() -> int:
"""Get the default token expiration time.
Returns:
The default token expiration time.
"""
return get_config().redis_token_expiration
class StateManagerRedis(StateManager):
"""A state manager that stores states in redis."""
@ -2326,10 +2343,10 @@ class StateManagerRedis(StateManager):
redis: Redis
# The token expiration time (s).
token_expiration: int = config.redis_token_expiration
token_expiration: int = pydantic.Field(default_factory=_default_token_expiration)
# The maximum time to hold a lock (ms).
lock_expiration: int = config.redis_lock_expiration
lock_expiration: int = pydantic.Field(default_factory=_default_lock_expiration)
# The keyspace subscription string when redis is waiting for lock to be released
_redis_notify_keyspace_events: str = (