Skip to content

Commit 1a3fba1

Browse files
committed
Merge branch 'main' into enable-wide-assortion-of-ruff-rules
2 parents cd31fa9 + ae66ab6 commit 1a3fba1

8 files changed

Lines changed: 209 additions & 181 deletions

File tree

.github/actions/setup_build_env/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ runs:
3434
prune-cache: false
3535
activate-environment: true
3636
cache-dependency-glob: "uv.lock"
37+
- name: Install Dependencies
38+
if: inputs.run-uv-sync == 'true'
39+
run: uv sync
40+
shell: bash

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fail_fast = true
228228

229229
[[tool.pre-commit.repos]]
230230
repo = "https://github.com/astral-sh/ruff-pre-commit"
231-
rev = "v0.11.11"
231+
rev = "v0.11.12"
232232
hooks = [
233233
{ id = "ruff-format", args = [
234234
"reflex",

reflex/compiler/compiler.py

Lines changed: 63 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import sys
56
from collections.abc import Iterable, Sequence
67
from datetime import datetime
78
from inspect import getmodule
@@ -682,12 +683,13 @@ def into_component(component: Component | ComponentCallable) -> Component:
682683
"""
683684
if (converted := _into_component_once(component)) is not None:
684685
return converted
686+
if not callable(component):
687+
raise TypeError(
688+
f"Expected a Component or callable, got {component!r} of type {type(component)}"
689+
)
690+
685691
try:
686-
if (
687-
callable(component)
688-
and (converted := _into_component_once(component())) is not None
689-
):
690-
return converted
692+
component_called = component()
691693
except KeyError as e:
692694
if isinstance(e, ReflexError):
693695
raise
@@ -725,8 +727,12 @@ def into_component(component: Component | ComponentCallable) -> Component:
725727
).with_traceback(e.__traceback__) from None
726728
raise
727729

728-
msg = f"Expected a Component, got {type(component)}"
729-
raise TypeError(msg)
730+
if (converted := _into_component_once(component_called)) is not None:
731+
return converted
732+
733+
raise TypeError(
734+
f"Expected a Component, got {component_called!r} of type {type(component_called)}"
735+
)
730736

731737

732738
def compile_unevaluated_page(
@@ -747,52 +753,61 @@ def compile_unevaluated_page(
747753
748754
Returns:
749755
The compiled component and whether state should be enabled.
756+
757+
Raises:
758+
Exception: If an error occurs while evaluating the page.
750759
"""
751-
# Generate the component if it is a callable.
752-
component = into_component(page.component)
760+
try:
761+
# Generate the component if it is a callable.
762+
component = into_component(page.component)
753763

754-
component._add_style_recursive(style or {}, theme)
764+
component._add_style_recursive(style or {}, theme)
755765

756-
enable_state = False
757-
# Ensure state is enabled if this page uses state.
758-
if state is None:
759-
if page.on_load or component._has_stateful_event_triggers():
760-
enable_state = True
761-
else:
762-
for var in component._get_vars(include_children=True):
763-
var_data = var._get_all_var_data()
764-
if not var_data:
765-
continue
766-
if not var_data.state:
767-
continue
766+
enable_state = False
767+
# Ensure state is enabled if this page uses state.
768+
if state is None:
769+
if page.on_load or component._has_stateful_event_triggers():
768770
enable_state = True
769-
break
770-
771-
from reflex.app import OverlayFragment
772-
from reflex.utils.format import make_default_page_title
773-
774-
component = OverlayFragment.create(component)
775-
776-
meta_args = {
777-
"title": (
778-
page.title
779-
if page.title is not None
780-
else make_default_page_title(get_config().app_name, route)
781-
),
782-
"image": page.image,
783-
"meta": page.meta,
784-
}
785-
786-
if page.description is not None:
787-
meta_args["description"] = page.description
788-
789-
# Add meta information to the component.
790-
utils.add_meta(
791-
component,
792-
**meta_args,
793-
)
771+
else:
772+
for var in component._get_vars(include_children=True):
773+
var_data = var._get_all_var_data()
774+
if not var_data:
775+
continue
776+
if not var_data.state:
777+
continue
778+
enable_state = True
779+
break
780+
781+
from reflex.app import OverlayFragment
782+
from reflex.utils.format import make_default_page_title
783+
784+
component = OverlayFragment.create(component)
785+
786+
meta_args = {
787+
"title": (
788+
page.title
789+
if page.title is not None
790+
else make_default_page_title(get_config().app_name, route)
791+
),
792+
"image": page.image,
793+
"meta": page.meta,
794+
}
795+
796+
if page.description is not None:
797+
meta_args["description"] = page.description
798+
799+
# Add meta information to the component.
800+
utils.add_meta(
801+
component,
802+
**meta_args,
803+
)
794804

795-
return component, enable_state
805+
except Exception as e:
806+
if sys.version_info >= (3, 11):
807+
e.add_note(f"Happened while evaluating page {route!r}")
808+
raise
809+
else:
810+
return component, enable_state
796811

797812

798813
class ExecutorSafeFunctions:

reflex/components/radix/primitives/progress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class ProgressComponent(RadixPrimitiveComponentWithClassName):
1616
"""A Progress component."""
1717

18-
library = "@radix-ui/react-progress@1.1.6"
18+
library = "@radix-ui/react-progress@1.1.7"
1919

2020

2121
class ProgressRoot(ProgressComponent):

reflex/components/radix/primitives/slider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class SliderComponent(RadixPrimitiveComponentWithClassName):
1818
"""Base class for all @radix-ui/react-slider components."""
1919

20-
library = "@radix-ui/react-slider@1.3.4"
20+
library = "@radix-ui/react-slider@1.3.5"
2121

2222

2323
def on_value_event_spec(

reflex/constants/installer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Bun(SimpleNamespace):
1414
"""Bun constants."""
1515

1616
# The Bun version.
17-
VERSION = "1.2.14"
17+
VERSION = "1.2.15"
1818

1919
# Min Bun Version
2020
MIN_VERSION = "1.2.8"
@@ -137,7 +137,7 @@ def DEPENDENCIES(cls) -> dict[str, str]:
137137

138138
DEV_DEPENDENCIES = {
139139
"autoprefixer": "10.4.21",
140-
"postcss": "8.5.3",
140+
"postcss": "8.5.4",
141141
"postcss-import": "16.1.0",
142142
}
143143
OVERRIDES = {

reflex/utils/pyi_generator.py

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
PWD = Path.cwd()
3232

33+
PYI_HASHES = "pyi_hashes.json"
34+
3335
EXCLUDED_FILES = [
3436
"app.py",
3537
"component.py",
@@ -1264,45 +1266,48 @@ def scan_all(
12641266
file_parent = file_path.parent
12651267
while len(file_parent.parts) > len(top_dir.parts):
12661268
file_parent = file_parent.parent
1269+
while len(top_dir.parts) > len(file_parent.parts):
1270+
top_dir = top_dir.parent
12671271
while not file_parent.samefile(top_dir):
12681272
file_parent = file_parent.parent
12691273
top_dir = top_dir.parent
12701274

1271-
pyi_hashes_file = top_dir / "pyi_hashes.json"
1272-
if not pyi_hashes_file.exists():
1273-
while top_dir.parent and not (top_dir / "pyi_hashes.json").exists():
1274-
top_dir = top_dir.parent
1275-
another_pyi_hashes_file = top_dir / "pyi_hashes.json"
1276-
if another_pyi_hashes_file.exists():
1277-
pyi_hashes_file = another_pyi_hashes_file
1278-
1279-
pyi_hashes_file.write_text(
1280-
json.dumps(
1281-
dict(
1282-
zip(
1283-
[
1284-
f.relative_to(pyi_hashes_file.parent).as_posix()
1285-
for f in file_paths
1286-
],
1287-
hashes,
1288-
strict=True,
1289-
)
1290-
),
1291-
indent=2,
1292-
sort_keys=True,
1275+
while (
1276+
not top_dir.samefile(top_dir.parent)
1277+
and not (top_dir / PYI_HASHES).exists()
1278+
):
1279+
top_dir = top_dir.parent
1280+
1281+
pyi_hashes_file = top_dir / PYI_HASHES
1282+
1283+
if pyi_hashes_file.exists():
1284+
pyi_hashes_file.write_text(
1285+
json.dumps(
1286+
dict(
1287+
zip(
1288+
[
1289+
f.relative_to(pyi_hashes_file.parent).as_posix()
1290+
for f in file_paths
1291+
],
1292+
hashes,
1293+
strict=True,
1294+
)
1295+
),
1296+
indent=2,
1297+
sort_keys=True,
1298+
)
1299+
+ "\n",
12931300
)
1294-
+ "\n",
1295-
)
12961301
elif file_paths:
12971302
file_paths = list(map(Path, file_paths))
12981303
pyi_hashes_parent = file_paths[0].parent
12991304
while (
1300-
pyi_hashes_parent.parent
1301-
and not (pyi_hashes_parent / "pyi_hashes.json").exists()
1305+
not pyi_hashes_parent.samefile(pyi_hashes_parent.parent)
1306+
and not (pyi_hashes_parent / PYI_HASHES).exists()
13021307
):
13031308
pyi_hashes_parent = pyi_hashes_parent.parent
13041309

1305-
pyi_hashes_file = pyi_hashes_parent / "pyi_hashes.json"
1310+
pyi_hashes_file = pyi_hashes_parent / PYI_HASHES
13061311
if pyi_hashes_file.exists():
13071312
pyi_hashes = json.loads(pyi_hashes_file.read_text())
13081313
for file_path, hashed_content in zip(

0 commit comments

Comments
 (0)