Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use old serializer system in LiteralVar #3875

Merged
merged 77 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e46aaf3
use serializer system
adhami3310 Sep 3, 2024
03d0f3e
add checks for unsupported operands
adhami3310 Sep 3, 2024
29968c3
and and or are now supported
adhami3310 Sep 3, 2024
ef909f8
format
adhami3310 Sep 3, 2024
f0a2221
remove unnecessary call to JSON
adhami3310 Sep 3, 2024
74262b0
put base before rest
adhami3310 Sep 3, 2024
160233a
fix failing testcase
adhami3310 Sep 3, 2024
84159b5
add hinting to get static analysis to complain
adhami3310 Sep 4, 2024
65d2e8b
damn
adhami3310 Sep 4, 2024
fbe6386
big changes
adhami3310 Sep 5, 2024
f2cee4f
get typeguard from extensions
adhami3310 Sep 5, 2024
0fdc506
please darglint
adhami3310 Sep 5, 2024
566f791
dangit darglint
adhami3310 Sep 5, 2024
175696c
remove one from vars
adhami3310 Sep 5, 2024
3a1301a
add without data and use it in plotly
adhami3310 Sep 5, 2024
47c2f21
DARGLINT
adhami3310 Sep 5, 2024
0d595de
change format for special props
adhami3310 Sep 5, 2024
e789717
add pyi
adhami3310 Sep 5, 2024
0e648c3
delete instances of Var.create
adhami3310 Sep 5, 2024
bdede8a
modify client state to work
adhami3310 Sep 5, 2024
f7f9d1a
fixed so much
adhami3310 Sep 5, 2024
ccc5799
remove every Var.create
adhami3310 Sep 5, 2024
69ab1a7
delete all basevar stuff
adhami3310 Sep 5, 2024
b7c89ad
checkpoint
adhami3310 Sep 6, 2024
42f2674
fix pyi
adhami3310 Sep 6, 2024
ac13e19
get older python to work
adhami3310 Sep 6, 2024
1e57600
dangit darglint
adhami3310 Sep 6, 2024
e82d79a
add simple fix to last failing testcase
adhami3310 Sep 6, 2024
cd756d2
remove var name unwrapped and put client state on immutable var
adhami3310 Sep 6, 2024
129dea0
fix older python
adhami3310 Sep 6, 2024
96888b3
fox event issues
adhami3310 Sep 6, 2024
e9bc9dc
change forms pyi
adhami3310 Sep 6, 2024
4552d08
make test less strict
adhami3310 Sep 6, 2024
fb2e86c
use rx state directly
adhami3310 Sep 6, 2024
81c51d3
add typeignore to page_id
adhami3310 Sep 6, 2024
6fb991f
implement foreach
adhami3310 Sep 6, 2024
6127592
delete .web states folder silly
adhami3310 Sep 6, 2024
a75bc81
update reflex chakra
adhami3310 Sep 6, 2024
0ad634b
fix issue when on mount or on unmount is not set
adhami3310 Sep 7, 2024
d3217ef
nuke Var
adhami3310 Sep 7, 2024
46e954b
run pyi
adhami3310 Sep 7, 2024
6db0701
import immutablevar in critical location
adhami3310 Sep 7, 2024
4fd2ecd
delete unwrap vars
adhami3310 Sep 7, 2024
ca975b1
bring back array ref
adhami3310 Sep 7, 2024
00e32ad
fix style props in app
adhami3310 Sep 7, 2024
993c5e2
/health endpoint for K8 Liveness and Readiness probes (#3855)
samarth9201 Sep 4, 2024
c5115de
Update find_replace (#3886)
samarth9201 Sep 4, 2024
972e793
[REF-3592]Promote `rx.progress` from radix themes (#3878)
ElijahAhianyo Sep 5, 2024
5d74619
Use correct flexgen backend URL (#3891)
masenf Sep 5, 2024
2b2182c
Remove demo template (#3888)
ElijahAhianyo Sep 5, 2024
e36fe8b
gitignore .web (#3885)
benedikt-bartscher Sep 5, 2024
5712f10
update overflowY in AUTO_HEIGHT_JS from hidden to scroll (#3882)
VishDev12 Sep 5, 2024
d29e2c1
Retain mutability inside `async with self` block (#3884)
masenf Sep 5, 2024
7ad4016
Include child imports in markdown component_map (#3883)
masenf Sep 5, 2024
7ee7f52
[REF-3570] Remove deprecated REDIS_URL syntax (#3892)
masenf Sep 5, 2024
c9aeb43
mixin computed vars should only be applied to highest level state (#3…
benedikt-bartscher Sep 9, 2024
f54eefb
improve state hierarchy validation, drop old testing special case (#3…
benedikt-bartscher Sep 9, 2024
e693e17
fix var dependency dicts (#3842)
benedikt-bartscher Sep 9, 2024
25d1ace
Adding array to array pluck operation. (#3868)
abulvenz Sep 9, 2024
99548d6
fix initial state without cv fallback (#3670)
benedikt-bartscher Sep 9, 2024
e17ab7c
add fragment to foreach (#3877)
adhami3310 Sep 9, 2024
1ea6d0c
Update docker-example (#3324)
masenf Sep 9, 2024
2dc0fd1
/health endpoint for K8 Liveness and Readiness probes (#3855)
samarth9201 Sep 4, 2024
8d622ae
/health endpoint for K8 Liveness and Readiness probes (#3855)
samarth9201 Sep 4, 2024
d02b752
Merge branch 'main' into use-old-serializer-in-literalvar
adhami3310 Sep 9, 2024
e0553b9
[REF-3570] Remove deprecated REDIS_URL syntax (#3892)
masenf Sep 5, 2024
94064a6
/health endpoint for K8 Liveness and Readiness probes (#3855)
samarth9201 Sep 4, 2024
5b8ab1e
[REF-3570] Remove deprecated REDIS_URL syntax (#3892)
masenf Sep 5, 2024
d3ab0c4
Merging
adhami3310 Sep 9, 2024
a9837ef
remove extra var
adhami3310 Sep 9, 2024
3e12fe1
resolve typo
adhami3310 Sep 9, 2024
4efea75
write better doc for var.create
adhami3310 Sep 9, 2024
bd43816
return var value when we know it's literal var
adhami3310 Sep 9, 2024
aded66b
fix unit test
adhami3310 Sep 9, 2024
6e2e8aa
less bloat for ToOperations
adhami3310 Sep 9, 2024
399e01a
simplify ImmutableComputedVar.__get__ (#3902)
benedikt-bartscher Sep 9, 2024
118bdf0
Merging
adhami3310 Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions integration/test_dynamic_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def DynamicRoute():

class DynamicState(rx.State):
order: List[str] = []
page_id: str = ""

def on_load(self):
self.order.append(f"{self.router.page.path}-{self.page_id or 'no page id'}")
Expand All @@ -47,7 +46,7 @@ def index():
is_read_only=True,
id="token",
),
rc.input(value=DynamicState.page_id, is_read_only=True, id="page_id"),
rc.input(value=rx.State.page_id, is_read_only=True, id="page_id"), # type: ignore
rc.input(
value=DynamicState.router.page.raw_path,
is_read_only=True,
Expand All @@ -74,9 +73,9 @@ def redirect_page():
return rx.fragment(rx.text("redirecting..."))

app = rx.App(state=rx.State)
app.add_page(index)
app.add_page(index, route="/page/[page_id]", on_load=DynamicState.on_load) # type: ignore
app.add_page(index, route="/static/x", on_load=DynamicState.on_load) # type: ignore
app.add_page(index)
app.add_custom_404_page(on_load=DynamicState.on_load) # type: ignore


Expand Down
2 changes: 1 addition & 1 deletion integration/test_tailwind.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_tailwind_app(tailwind_app: AppHarness, tailwind_disabled: bool):
assert len(paragraphs) == 3
for p in paragraphs:
assert tailwind_app.poll_for_content(p, exp_not_equal="") == PARAGRAPH_TEXT
assert p.value_of_css_property("font-family") == '"monospace"'
assert p.value_of_css_property("font-family") == "monospace"
if tailwind_disabled:
# expect default color, not "text-red-500" from tailwind utility class
assert p.value_of_css_property("color") not in TEXT_RED_500_COLOR
Expand Down
632 changes: 317 additions & 315 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions reflex/.templates/jinja/web/pages/utils.js.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
{% macro render_match_tag(component) %}
{
(() => {
switch (JSON.stringify({{ component.cond._var_name_unwrapped }})) {
switch (JSON.stringify({{ component.cond._var_name }})) {
{% for case in component.match_cases %}
{% for condition in case[:-1] %}
case JSON.stringify({{ condition._var_name_unwrapped }}):
case JSON.stringify({{ condition._var_name }}):
{% endfor %}
return {{ case[-1] }};
break;
Expand Down
2 changes: 1 addition & 1 deletion reflex/.templates/jinja/web/utils/theme.js.jinja2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default {{ theme|json_dumps }}
export default {{ theme }}
9 changes: 4 additions & 5 deletions reflex/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
StatefulComponent,
)
from reflex.config import get_config
from reflex.ivars.base import LiteralVar
from reflex.ivars.base import ImmutableVar, LiteralVar
from reflex.state import BaseState
from reflex.style import SYSTEM_COLOR_MODE
from reflex.utils.exec import is_prod_mode
from reflex.utils.imports import ImportVar
from reflex.utils.prerequisites import get_web_dir
from reflex.vars import Var


def _compile_document_root(root: Component) -> str:
Expand Down Expand Up @@ -58,7 +57,7 @@ def _compile_app(app_root: Component) -> str:
)


def _compile_theme(theme: dict) -> str:
def _compile_theme(theme: str) -> str:
"""Compile the theme.

Args:
Expand Down Expand Up @@ -321,7 +320,7 @@ def _compile_tailwind(
def compile_document_root(
head_components: list[Component],
html_lang: Optional[str] = None,
html_custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
html_custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
) -> tuple[str, str]:
"""Compile the document root.

Expand Down Expand Up @@ -378,7 +377,7 @@ def compile_theme(style: ComponentStyle) -> tuple[str, str]:
theme = utils.create_theme(style)

# Compile the theme.
code = _compile_theme(theme)
code = _compile_theme(str(LiteralVar.create(theme)))
return output_path, code


Expand Down
4 changes: 2 additions & 2 deletions reflex/compiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any, Callable, Dict, Optional, Type, Union
from urllib.parse import urlparse

from reflex.ivars.base import ImmutableVar
from reflex.utils.prerequisites import get_web_dir

try:
Expand All @@ -32,7 +33,6 @@
from reflex.style import Style
from reflex.utils import console, format, imports, path_ops
from reflex.utils.imports import ImportVar, ParsedImportDict
from reflex.vars import Var

# To re-export this function.
merge_imports = imports.merge_imports
Expand Down Expand Up @@ -286,7 +286,7 @@ def compile_custom_component(
def create_document_root(
head_components: list[Component] | None = None,
html_lang: Optional[str] = None,
html_custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
html_custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
) -> Component:
"""Create the document root.

Expand Down
44 changes: 27 additions & 17 deletions reflex/components/base/app_wrap.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ from typing import Any, Callable, Dict, Optional, Union, overload

from reflex.components.base.fragment import Fragment
from reflex.event import EventHandler, EventSpec
from reflex.ivars.base import ImmutableVar
from reflex.style import Style
from reflex.vars import Var

class AppWrap(Fragment):
@overload
Expand All @@ -21,41 +21,51 @@ class AppWrap(Fragment):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
on_blur: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mount: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mouse_down: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_enter: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_leave: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_move: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_out: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_over: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
**props,
) -> "AppWrap":
Expand Down
4 changes: 1 addition & 3 deletions reflex/components/base/bare.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ def create(cls, contents: Any) -> Component:
"""
if isinstance(contents, ImmutableVar):
return cls(contents=contents)
if isinstance(contents, Var):
contents = contents.to(str)
else:
contents = str(contents) if contents is not None else ""
return cls(contents=contents) # type: ignore
Expand All @@ -39,7 +37,7 @@ def _render(self) -> Tag:
return Tagless(contents=f"{{{str(self.contents)}}}")
return Tagless(contents=str(self.contents))

def _get_vars(self, include_children: bool = False) -> Iterator[Var]:
def _get_vars(self, include_children: bool = False) -> Iterator[ImmutableVar]:
"""Walk all Vars used in this component.

Args:
Expand Down
44 changes: 27 additions & 17 deletions reflex/components/base/body.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ from typing import Any, Callable, Dict, Optional, Union, overload

from reflex.components.component import Component
from reflex.event import EventHandler, EventSpec
from reflex.ivars.base import ImmutableVar
from reflex.style import Style
from reflex.vars import Var

class Body(Component):
@overload
Expand All @@ -21,41 +21,51 @@ class Body(Component):
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_click: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
custom_attrs: Optional[Dict[str, Union[ImmutableVar, str]]] = None,
on_blur: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mount: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_focus: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mount: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_mouse_down: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_enter: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_leave: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_move: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_out: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_over: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
on_scroll: Optional[Union[EventHandler, EventSpec, list, Callable, Var]] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, Callable, Var]
Union[EventHandler, EventSpec, list, Callable, ImmutableVar]
] = None,
**props,
) -> "Body":
Expand Down
Loading
Loading