reflex 0.5.1__py3-none-any.whl → 0.5.1a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

reflex/app.py CHANGED
@@ -1068,12 +1068,13 @@ async def process(
1068
1068
  client_ip: The client_ip.
1069
1069
 
1070
1070
  Raises:
1071
- Exception: If a reflex specific error occurs during processing the event.
1071
+ ReflexError: If a reflex specific error occurs during processing the event.
1072
1072
 
1073
1073
  Yields:
1074
1074
  The state updates after processing the event.
1075
1075
  """
1076
1076
  from reflex.utils import telemetry
1077
+ from reflex.utils.exceptions import ReflexError
1077
1078
 
1078
1079
  try:
1079
1080
  # Add request data to the state.
@@ -1117,8 +1118,8 @@ async def process(
1117
1118
 
1118
1119
  # Yield the update.
1119
1120
  yield update
1120
- except Exception as ex:
1121
- telemetry.send_error(ex, context="backend")
1121
+ except ReflexError as ex:
1122
+ telemetry.send("error", context="backend", detail=str(ex))
1122
1123
  raise
1123
1124
 
1124
1125
 
@@ -4,14 +4,12 @@ Only the app attribute is explicitly exposed.
4
4
  from concurrent.futures import ThreadPoolExecutor
5
5
 
6
6
  from reflex import constants
7
- from reflex.utils import telemetry
8
7
  from reflex.utils.exec import is_prod_mode
9
8
  from reflex.utils.prerequisites import get_app
10
9
 
11
10
  if "app" != constants.CompileVars.APP:
12
11
  raise AssertionError("unexpected variable name for 'app'")
13
12
 
14
- telemetry.send("compile")
15
13
  app_module = get_app(reload=False)
16
14
  app = getattr(app_module, constants.CompileVars.APP)
17
15
  # For py3.8 and py3.9 compatibility when redis is used, we MUST add any decorator pages
@@ -31,6 +29,5 @@ del app_module
31
29
  del compile_future
32
30
  del get_app
33
31
  del is_prod_mode
34
- del telemetry
35
32
  del constants
36
33
  del ThreadPoolExecutor
@@ -1,8 +1,7 @@
1
1
  """Create a list of components from an iterable."""
2
-
3
2
  from __future__ import annotations
4
3
 
5
- from typing import Any, Dict, Optional, Union, overload
4
+ from typing import Any, Dict, Optional, overload
6
5
 
7
6
  from reflex.components.base.fragment import Fragment
8
7
  from reflex.components.component import BaseComponent, Component, MemoizationLeaf
@@ -11,7 +10,7 @@ from reflex.constants import Dirs
11
10
  from reflex.constants.colors import Color
12
11
  from reflex.style import LIGHT_COLOR_MODE, color_mode
13
12
  from reflex.utils import format, imports
14
- from reflex.vars import Var, VarData
13
+ from reflex.vars import BaseVar, Var, VarData
15
14
 
16
15
  _IS_TRUE_IMPORT = {
17
16
  f"/{Dirs.STATE_PATH}": [imports.ImportVar(tag="isTrue")],
@@ -172,11 +171,6 @@ def cond(condition: Any, c1: Any, c2: Any = None):
172
171
  c2 = create_var(c2)
173
172
  var_datas.extend([c1._var_data, c2._var_data])
174
173
 
175
- c1_type = c1._var_type if isinstance(c1, Var) else type(c1)
176
- c2_type = c2._var_type if isinstance(c2, Var) else type(c2)
177
-
178
- var_type = c1_type if c1_type == c2_type else Union[c1_type, c2_type]
179
-
180
174
  # Create the conditional var.
181
175
  return cond_var._replace(
182
176
  _var_name=format.format_cond(
@@ -185,7 +179,7 @@ def cond(condition: Any, c1: Any, c2: Any = None):
185
179
  false_value=c2,
186
180
  is_prop=True,
187
181
  ),
188
- _var_type=var_type,
182
+ _var_type=c1._var_type if isinstance(c1, BaseVar) else type(c1),
189
183
  _var_is_local=False,
190
184
  _var_full_name_needs_state_prefix=False,
191
185
  merge_var_data=VarData.merge(*var_datas),
reflex/state.py CHANGED
@@ -1476,6 +1476,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1476
1476
  StateUpdate object
1477
1477
  """
1478
1478
  from reflex.utils import telemetry
1479
+ from reflex.utils.exceptions import ReflexError
1479
1480
 
1480
1481
  # Get the function to process the event.
1481
1482
  fn = functools.partial(handler.fn, state)
@@ -1515,7 +1516,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1515
1516
  except Exception as ex:
1516
1517
  error = traceback.format_exc()
1517
1518
  print(error)
1518
- telemetry.send_error(ex, context="backend")
1519
+ if isinstance(ex, ReflexError):
1520
+ telemetry.send("error", context="backend", detail=str(ex))
1519
1521
  yield state._as_state_update(
1520
1522
  handler,
1521
1523
  window_alert("An error occurred. See logs for details."),
@@ -233,8 +233,9 @@ def get_app(reload: bool = False) -> ModuleType:
233
233
 
234
234
  Raises:
235
235
  RuntimeError: If the app name is not set in the config.
236
+ exceptions.ReflexError: Reflex specific errors.
236
237
  """
237
- from reflex.utils import telemetry
238
+ from reflex.utils import exceptions, telemetry
238
239
 
239
240
  try:
240
241
  os.environ[constants.RELOAD_CONFIG] = str(reload)
@@ -258,8 +259,8 @@ def get_app(reload: bool = False) -> ModuleType:
258
259
  importlib.reload(app)
259
260
 
260
261
  return app
261
- except Exception as ex:
262
- telemetry.send_error(ex, context="frontend")
262
+ except exceptions.ReflexError as ex:
263
+ telemetry.send("error", context="frontend", detail=str(ex))
263
264
  raise
264
265
 
265
266
 
reflex/utils/telemetry.py CHANGED
@@ -2,10 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import asyncio
6
5
  import multiprocessing
7
6
  import platform
8
- import warnings
9
7
 
10
8
  try:
11
9
  from datetime import UTC, datetime
@@ -159,7 +157,17 @@ def _send_event(event_data: dict) -> bool:
159
157
  return False
160
158
 
161
159
 
162
- def _send(event, telemetry_enabled, **kwargs):
160
+ def send(event: str, telemetry_enabled: bool | None = None, **kwargs) -> bool:
161
+ """Send anonymous telemetry for Reflex.
162
+
163
+ Args:
164
+ event: The event name.
165
+ telemetry_enabled: Whether to send the telemetry (If None, get from config).
166
+ kwargs: Additional data to send with the event.
167
+
168
+ Returns:
169
+ Whether the telemetry was sent successfully.
170
+ """
163
171
  from reflex.config import get_config
164
172
 
165
173
  # Get the telemetry_enabled from the config if it is not specified.
@@ -174,37 +182,3 @@ def _send(event, telemetry_enabled, **kwargs):
174
182
  if not event_data:
175
183
  return False
176
184
  return _send_event(event_data)
177
-
178
-
179
- def send(event: str, telemetry_enabled: bool | None = None, **kwargs):
180
- """Send anonymous telemetry for Reflex.
181
-
182
- Args:
183
- event: The event name.
184
- telemetry_enabled: Whether to send the telemetry (If None, get from config).
185
- kwargs: Additional data to send with the event.
186
- """
187
-
188
- async def async_send(event, telemetry_enabled, **kwargs):
189
- return _send(event, telemetry_enabled, **kwargs)
190
-
191
- try:
192
- # Within an event loop context, send the event asynchronously.
193
- asyncio.create_task(async_send(event, telemetry_enabled, **kwargs))
194
- except RuntimeError:
195
- # If there is no event loop, send the event synchronously.
196
- warnings.filterwarnings("ignore", category=RuntimeWarning)
197
- _send(event, telemetry_enabled, **kwargs)
198
-
199
-
200
- def send_error(error: Exception, context: str):
201
- """Send an error event.
202
-
203
- Args:
204
- error: The error to send.
205
- context: The context of the error (e.g. "frontend" or "backend")
206
-
207
- Returns:
208
- Whether the telemetry was sent successfully.
209
- """
210
- return send("error", detail=type(error).__name__, context=context)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflex
3
- Version: 0.5.1
3
+ Version: 0.5.1a1
4
4
  Summary: Web apps in pure Python.
5
5
  Home-page: https://reflex.dev
6
6
  License: Apache-2.0
@@ -66,8 +66,8 @@ reflex/__init__.py,sha256=fzBYk8qUFWkUlD3U-97xEAdv9N1tTMRmAzQat_9cZW0,5831
66
66
  reflex/__init__.pyi,sha256=y4jPgnR9f6xOpFAK9-WM7p-T05Y5jGFYkx7Thdok_3I,7791
67
67
  reflex/__main__.py,sha256=6cVrGEyT3j3tEvlEVUatpaYfbB5EF3UVY-6vc_Z7-hw,108
68
68
  reflex/admin.py,sha256=-bTxFUEoHo4X9FzmcSa6KSVVPpF7wh38lBvF67GhSvQ,373
69
- reflex/app.py,sha256=vROxTXBLlPCUjI_9_-8_S7XOaExVls2j-kUE50u6-W0,47127
70
- reflex/app_module_for_backend.py,sha256=zGsgZWpl11exOuH34JZUimNgBnWpjL7WH4SW6LItxgY,1227
69
+ reflex/app.py,sha256=xpYYYPmlXtbj13arDnV9oyw3lgxBictyh60AGEnwzsk,47198
70
+ reflex/app_module_for_backend.py,sha256=_QFY5tZYO44C9h_yhGLn0LR27GXsuniBWAJqd80oQBw,1152
71
71
  reflex/base.py,sha256=nqvgm-f1Fcj1WQrphKFniZWIM13bzr48OgfPBo1KZd8,4274
72
72
  reflex/compiler/__init__.py,sha256=r8jqmDSFf09iV2lHlNhfc9XrTLjNxfDNwPYlxS4cmHE,27
73
73
  reflex/compiler/compiler.py,sha256=_ywbGHWnyM6tqPV-oriyBhFkblm5jQSJ6UuZT0LtkBo,17455
@@ -240,7 +240,7 @@ reflex/components/core/banner.pyi,sha256=Su21s78LOsIyYy3n7rtBeYDgXl2PO2Oo9cMAztP
240
240
  reflex/components/core/client_side_routing.py,sha256=mdZsGuc1V9qvOE0TaLEnXmXo0qHuPjc_dZrSjnlZsqc,1873
241
241
  reflex/components/core/client_side_routing.pyi,sha256=7Zel95b6tqfW0ulIJEHh9fmG_6av9eNeNjtORZ73jjM,6264
242
242
  reflex/components/core/colors.py,sha256=-hzVGLEq3TiqroqzMi_YzGBCPXMvkNsen3pS_NzIQNk,590
243
- reflex/components/core/cond.py,sha256=4jKcg9IBprpWAGY28Iymxe5Pu0UMEH-2e64zIkmf7_w,6163
243
+ reflex/components/core/cond.py,sha256=YwFrRdf9oDJyLhnPbFg73IlAWKy8yWCeIfTBMt9GtwY,6005
244
244
  reflex/components/core/debounce.py,sha256=HUR2yHkWEFawc64GZ7CakzLCx6WwCRhiPssAGJbtkSY,4820
245
245
  reflex/components/core/debounce.pyi,sha256=VGBX3hsRQo3xFP0xkYJuy25rDQ5rxRIk58mCV34fHSI,4216
246
246
  reflex/components/core/foreach.py,sha256=utMZhwg_k118EFwvO5jLXeQylZS3AAKS38fAIG9N2wE,4732
@@ -494,7 +494,7 @@ reflex/model.py,sha256=WMcJiT04HSM4fKTP9SIZJQoDrIO2vaPTsoao-X169V4,13227
494
494
  reflex/page.py,sha256=NPT0xMownZGTiYiRtrUJnvAe_4oEvlzEJEkG-vrGhqI,2077
495
495
  reflex/reflex.py,sha256=VJZAwe9lIqbS3VB3QkP5-OMmNXmM4gi-5TWMCJgZPcc,17826
496
496
  reflex/route.py,sha256=WZS7stKgO94nekFFYHaOqNgN3zZGpJb3YpGF4ViTHmw,4198
497
- reflex/state.py,sha256=muy6eMhNKwv0T-mcpSoKIvI_7MAsZPnb2Y4M8RtPVbI,107042
497
+ reflex/state.py,sha256=lTq7HBWVgB_Nk2vULyjfgqejym3B_zO_iZIPlSJ8AIw,107161
498
498
  reflex/style.py,sha256=iqXJzDZ5pgkpaYHkIn_AZxu7iz1DmVg5mBSFShZhPSE,9389
499
499
  reflex/testing.py,sha256=vY6eRztzOVmrFqKdCVOEOICaFBuhF9K6948G68moNns,31461
500
500
  reflex/utils/__init__.py,sha256=y-AHKiRQAhk2oAkvn7W8cRVTZVK625ff8tTwvZtO7S4,24
@@ -507,17 +507,17 @@ reflex/utils/export.py,sha256=UJd4BYFW9_eexhLCP4C5Ri8Cq2tWAPNVspq70lPLCyo,2270
507
507
  reflex/utils/format.py,sha256=BFadhZX6oFvIZLQ0aUnul8SDN2iURSkFz-7tJcvDlRk,25149
508
508
  reflex/utils/imports.py,sha256=v_xLZiMn7UxxPu5mXln74tXi52wYKqPuZe11Ka31WuM,2309
509
509
  reflex/utils/path_ops.py,sha256=Vy6fU_bXvOcCvbXdTSmeLwy_C4h9seYU-3yIrVdZEZQ,4737
510
- reflex/utils/prerequisites.py,sha256=g2iXfhIv0-m_oK0lNr_p1D_54XFKj11Bgp4uaJLdAnU,52824
510
+ reflex/utils/prerequisites.py,sha256=MfpYv-M9VjfiEeDe_kw7FiO0MDPkHWerNxfOLDznyjE,52920
511
511
  reflex/utils/processes.py,sha256=3viom6wOhrZKgbSC6qvcRiQlYDKnHm1jgdJEcGyReFM,11972
512
512
  reflex/utils/pyi_generator.py,sha256=cOfDESTXjnIvJhi8-anKVDNllgpnsGd4OyRmwdw1z5Y,30637
513
513
  reflex/utils/serializers.py,sha256=bKY4UxwumFfzE-75tpCFQWRfCeXn301fALwCAUgzgDw,9037
514
- reflex/utils/telemetry.py,sha256=t4cvQmoAxTKAWF53vGH6ZEX5QYrK_KEcarmvMy-4_E4,5568
514
+ reflex/utils/telemetry.py,sha256=EAly34tKjlZuThKAmCrDZBEfFphrPv1BDZlBezFNCW8,4735
515
515
  reflex/utils/types.py,sha256=1CJQsNf2wMrMJi-3th7eELZ3MFOFUBgoIs3j5rU-MNE,15152
516
516
  reflex/utils/watch.py,sha256=HzGrHQIZ_62Di0BO46kd2AZktNA3A6nFIBuf8c6ip30,2609
517
517
  reflex/vars.py,sha256=MlooFk2EYY-1FeaJOSDovBWKGiEhVgR9Nrk_feid0FI,69074
518
518
  reflex/vars.pyi,sha256=p7rrP7ZcV0KN26a8LSqjTWP7IzZXXSee0H9Rl4fjEtg,5753
519
- reflex-0.5.1.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
520
- reflex-0.5.1.dist-info/METADATA,sha256=Ept4Jo51n75bCE-F-Bc9CIxUc4gUCPLe6r-iGz31dDk,12087
521
- reflex-0.5.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
522
- reflex-0.5.1.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
523
- reflex-0.5.1.dist-info/RECORD,,
519
+ reflex-0.5.1a1.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
520
+ reflex-0.5.1a1.dist-info/METADATA,sha256=nACMw97nVC4Ul_sdvuZ4SWba1QLSUhsuRFCRjrCFRUw,12089
521
+ reflex-0.5.1a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
522
+ reflex-0.5.1a1.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
523
+ reflex-0.5.1a1.dist-info/RECORD,,