reflex 0.7.13a2__py3-none-any.whl → 0.7.14a1__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.

Files changed (256) hide show
  1. reflex/.templates/apps/blank/code/blank.py +0 -2
  2. reflex/app.py +64 -69
  3. reflex/app_mixins/lifespan.py +2 -3
  4. reflex/app_mixins/middleware.py +1 -0
  5. reflex/app_mixins/mixin.py +0 -1
  6. reflex/assets.py +6 -3
  7. reflex/base.py +3 -2
  8. reflex/compiler/compiler.py +77 -64
  9. reflex/compiler/utils.py +8 -6
  10. reflex/components/base/app_wrap.pyi +0 -1
  11. reflex/components/base/bare.py +5 -7
  12. reflex/components/base/body.pyi +0 -1
  13. reflex/components/base/document.pyi +0 -5
  14. reflex/components/base/error_boundary.pyi +0 -1
  15. reflex/components/base/fragment.pyi +0 -1
  16. reflex/components/base/head.pyi +0 -2
  17. reflex/components/base/link.pyi +0 -2
  18. reflex/components/base/meta.py +2 -1
  19. reflex/components/base/meta.pyi +0 -4
  20. reflex/components/base/script.py +2 -1
  21. reflex/components/base/script.pyi +0 -1
  22. reflex/components/base/strict_mode.pyi +0 -1
  23. reflex/components/component.py +38 -40
  24. reflex/components/core/auto_scroll.pyi +0 -1
  25. reflex/components/core/banner.pyi +0 -6
  26. reflex/components/core/breakpoints.py +9 -11
  27. reflex/components/core/client_side_routing.pyi +0 -2
  28. reflex/components/core/clipboard.pyi +0 -1
  29. reflex/components/core/colors.py +10 -7
  30. reflex/components/core/cond.py +4 -2
  31. reflex/components/core/debounce.py +5 -3
  32. reflex/components/core/debounce.pyi +0 -1
  33. reflex/components/core/foreach.py +8 -6
  34. reflex/components/core/html.py +3 -3
  35. reflex/components/core/html.pyi +0 -1
  36. reflex/components/core/match.py +19 -17
  37. reflex/components/core/sticky.pyi +0 -4
  38. reflex/components/core/upload.pyi +0 -5
  39. reflex/components/datadisplay/code.py +1 -2
  40. reflex/components/datadisplay/code.pyi +0 -2
  41. reflex/components/datadisplay/dataeditor.py +7 -10
  42. reflex/components/datadisplay/dataeditor.pyi +0 -1
  43. reflex/components/datadisplay/logo.py +3 -4
  44. reflex/components/datadisplay/shiki_code_block.py +8 -11
  45. reflex/components/datadisplay/shiki_code_block.pyi +0 -3
  46. reflex/components/dynamic.py +2 -3
  47. reflex/components/el/__init__.pyi +2 -0
  48. reflex/components/el/element.pyi +0 -1
  49. reflex/components/el/elements/__init__.py +1 -0
  50. reflex/components/el/elements/__init__.pyi +3 -0
  51. reflex/components/el/elements/base.pyi +0 -1
  52. reflex/components/el/elements/forms.py +3 -4
  53. reflex/components/el/elements/forms.pyi +1 -18
  54. reflex/components/el/elements/inline.pyi +0 -28
  55. reflex/components/el/elements/media.py +26 -0
  56. reflex/components/el/elements/media.pyi +259 -25
  57. reflex/components/el/elements/metadata.py +0 -1
  58. reflex/components/el/elements/metadata.pyi +0 -6
  59. reflex/components/el/elements/other.pyi +0 -7
  60. reflex/components/el/elements/scripts.pyi +0 -3
  61. reflex/components/el/elements/sectioning.pyi +0 -15
  62. reflex/components/el/elements/tables.pyi +0 -10
  63. reflex/components/el/elements/typography.pyi +0 -15
  64. reflex/components/gridjs/datatable.py +10 -13
  65. reflex/components/gridjs/datatable.pyi +0 -2
  66. reflex/components/lucide/icon.py +10 -9
  67. reflex/components/lucide/icon.pyi +0 -3
  68. reflex/components/markdown/markdown.py +6 -8
  69. reflex/components/markdown/markdown.pyi +0 -1
  70. reflex/components/moment/moment.pyi +0 -1
  71. reflex/components/next/base.py +0 -2
  72. reflex/components/next/base.pyi +0 -3
  73. reflex/components/next/image.pyi +0 -1
  74. reflex/components/next/link.pyi +0 -1
  75. reflex/components/next/video.pyi +0 -1
  76. reflex/components/plotly/plotly.pyi +0 -9
  77. reflex/components/props.py +4 -3
  78. reflex/components/radix/primitives/accordion.pyi +0 -7
  79. reflex/components/radix/primitives/base.py +1 -3
  80. reflex/components/radix/primitives/base.pyi +0 -2
  81. reflex/components/radix/primitives/drawer.pyi +0 -11
  82. reflex/components/radix/primitives/form.py +4 -8
  83. reflex/components/radix/primitives/form.pyi +0 -12
  84. reflex/components/radix/primitives/progress.py +1 -1
  85. reflex/components/radix/primitives/progress.pyi +0 -5
  86. reflex/components/radix/primitives/slider.py +1 -1
  87. reflex/components/radix/primitives/slider.pyi +0 -5
  88. reflex/components/radix/themes/base.pyi +0 -8
  89. reflex/components/radix/themes/color_mode.pyi +0 -3
  90. reflex/components/radix/themes/components/alert_dialog.py +4 -2
  91. reflex/components/radix/themes/components/alert_dialog.pyi +4 -9
  92. reflex/components/radix/themes/components/aspect_ratio.py +1 -2
  93. reflex/components/radix/themes/components/aspect_ratio.pyi +1 -3
  94. reflex/components/radix/themes/components/avatar.py +5 -2
  95. reflex/components/radix/themes/components/avatar.pyi +1 -3
  96. reflex/components/radix/themes/components/badge.py +5 -2
  97. reflex/components/radix/themes/components/badge.pyi +1 -3
  98. reflex/components/radix/themes/components/button.py +2 -3
  99. reflex/components/radix/themes/components/button.pyi +1 -3
  100. reflex/components/radix/themes/components/callout.py +1 -2
  101. reflex/components/radix/themes/components/callout.pyi +1 -7
  102. reflex/components/radix/themes/components/card.py +1 -2
  103. reflex/components/radix/themes/components/card.pyi +1 -3
  104. reflex/components/radix/themes/components/checkbox.py +7 -4
  105. reflex/components/radix/themes/components/checkbox.pyi +1 -5
  106. reflex/components/radix/themes/components/checkbox_cards.py +1 -2
  107. reflex/components/radix/themes/components/checkbox_cards.pyi +1 -4
  108. reflex/components/radix/themes/components/checkbox_group.py +1 -2
  109. reflex/components/radix/themes/components/checkbox_group.pyi +1 -4
  110. reflex/components/radix/themes/components/context_menu.py +1 -1
  111. reflex/components/radix/themes/components/context_menu.pyi +1 -14
  112. reflex/components/radix/themes/components/data_list.py +1 -2
  113. reflex/components/radix/themes/components/data_list.pyi +1 -6
  114. reflex/components/radix/themes/components/dialog.py +4 -2
  115. reflex/components/radix/themes/components/dialog.pyi +4 -9
  116. reflex/components/radix/themes/components/dropdown_menu.py +5 -2
  117. reflex/components/radix/themes/components/dropdown_menu.pyi +4 -10
  118. reflex/components/radix/themes/components/hover_card.py +4 -2
  119. reflex/components/radix/themes/components/hover_card.pyi +4 -6
  120. reflex/components/radix/themes/components/icon_button.py +7 -8
  121. reflex/components/radix/themes/components/icon_button.pyi +1 -3
  122. reflex/components/radix/themes/components/inset.py +1 -2
  123. reflex/components/radix/themes/components/inset.pyi +1 -3
  124. reflex/components/radix/themes/components/popover.py +4 -2
  125. reflex/components/radix/themes/components/popover.pyi +4 -6
  126. reflex/components/radix/themes/components/progress.py +1 -2
  127. reflex/components/radix/themes/components/progress.pyi +1 -3
  128. reflex/components/radix/themes/components/radio.py +1 -2
  129. reflex/components/radix/themes/components/radio.pyi +1 -3
  130. reflex/components/radix/themes/components/radio_cards.py +1 -2
  131. reflex/components/radix/themes/components/radio_cards.pyi +1 -4
  132. reflex/components/radix/themes/components/radio_group.py +7 -5
  133. reflex/components/radix/themes/components/radio_group.pyi +1 -6
  134. reflex/components/radix/themes/components/scroll_area.py +1 -2
  135. reflex/components/radix/themes/components/scroll_area.pyi +1 -3
  136. reflex/components/radix/themes/components/segmented_control.py +1 -2
  137. reflex/components/radix/themes/components/segmented_control.pyi +1 -4
  138. reflex/components/radix/themes/components/select.py +5 -2
  139. reflex/components/radix/themes/components/select.pyi +1 -11
  140. reflex/components/radix/themes/components/separator.py +1 -2
  141. reflex/components/radix/themes/components/separator.pyi +1 -3
  142. reflex/components/radix/themes/components/skeleton.py +1 -2
  143. reflex/components/radix/themes/components/skeleton.pyi +1 -3
  144. reflex/components/radix/themes/components/slider.py +1 -2
  145. reflex/components/radix/themes/components/slider.pyi +1 -3
  146. reflex/components/radix/themes/components/spinner.py +1 -2
  147. reflex/components/radix/themes/components/spinner.pyi +1 -3
  148. reflex/components/radix/themes/components/switch.py +1 -2
  149. reflex/components/radix/themes/components/switch.pyi +1 -3
  150. reflex/components/radix/themes/components/table.py +1 -2
  151. reflex/components/radix/themes/components/table.pyi +1 -9
  152. reflex/components/radix/themes/components/tabs.py +1 -2
  153. reflex/components/radix/themes/components/tabs.pyi +1 -7
  154. reflex/components/radix/themes/components/text_area.py +5 -2
  155. reflex/components/radix/themes/components/text_area.pyi +1 -3
  156. reflex/components/radix/themes/components/text_field.py +5 -2
  157. reflex/components/radix/themes/components/text_field.pyi +1 -5
  158. reflex/components/radix/themes/components/tooltip.py +1 -2
  159. reflex/components/radix/themes/components/tooltip.pyi +1 -3
  160. reflex/components/radix/themes/layout/base.py +5 -2
  161. reflex/components/radix/themes/layout/base.pyi +5 -3
  162. reflex/components/radix/themes/layout/box.py +1 -2
  163. reflex/components/radix/themes/layout/box.pyi +1 -3
  164. reflex/components/radix/themes/layout/center.pyi +0 -1
  165. reflex/components/radix/themes/layout/container.py +1 -2
  166. reflex/components/radix/themes/layout/container.pyi +1 -3
  167. reflex/components/radix/themes/layout/flex.py +6 -2
  168. reflex/components/radix/themes/layout/flex.pyi +1 -3
  169. reflex/components/radix/themes/layout/grid.py +6 -2
  170. reflex/components/radix/themes/layout/grid.pyi +1 -3
  171. reflex/components/radix/themes/layout/list.py +2 -1
  172. reflex/components/radix/themes/layout/list.pyi +0 -5
  173. reflex/components/radix/themes/layout/section.py +1 -2
  174. reflex/components/radix/themes/layout/section.pyi +1 -3
  175. reflex/components/radix/themes/layout/spacer.pyi +0 -1
  176. reflex/components/radix/themes/layout/stack.py +1 -1
  177. reflex/components/radix/themes/layout/stack.pyi +0 -3
  178. reflex/components/radix/themes/typography/blockquote.py +1 -1
  179. reflex/components/radix/themes/typography/blockquote.pyi +1 -3
  180. reflex/components/radix/themes/typography/code.py +5 -1
  181. reflex/components/radix/themes/typography/code.pyi +1 -3
  182. reflex/components/radix/themes/typography/heading.py +1 -1
  183. reflex/components/radix/themes/typography/heading.pyi +1 -3
  184. reflex/components/radix/themes/typography/link.py +3 -2
  185. reflex/components/radix/themes/typography/link.pyi +1 -3
  186. reflex/components/radix/themes/typography/text.py +1 -1
  187. reflex/components/radix/themes/typography/text.pyi +1 -9
  188. reflex/components/react_player/audio.py +0 -2
  189. reflex/components/react_player/audio.pyi +0 -3
  190. reflex/components/react_player/react_player.pyi +0 -1
  191. reflex/components/react_player/video.py +0 -2
  192. reflex/components/react_player/video.pyi +0 -3
  193. reflex/components/recharts/__init__.py +1 -1
  194. reflex/components/recharts/__init__.pyi +1 -1
  195. reflex/components/recharts/cartesian.py +20 -25
  196. reflex/components/recharts/cartesian.pyi +20 -37
  197. reflex/components/recharts/charts.py +2 -1
  198. reflex/components/recharts/charts.pyi +0 -12
  199. reflex/components/recharts/general.pyi +0 -6
  200. reflex/components/recharts/polar.py +5 -4
  201. reflex/components/recharts/polar.pyi +4 -10
  202. reflex/components/recharts/recharts.py +12 -10
  203. reflex/components/recharts/recharts.pyi +10 -11
  204. reflex/components/sonner/toast.py +2 -2
  205. reflex/components/sonner/toast.pyi +0 -2
  206. reflex/components/suneditor/editor.py +2 -1
  207. reflex/components/suneditor/editor.pyi +0 -1
  208. reflex/components/tags/iter_tag.py +4 -2
  209. reflex/config.py +47 -35
  210. reflex/constants/base.py +3 -3
  211. reflex/constants/compiler.py +8 -6
  212. reflex/constants/installer.py +24 -15
  213. reflex/custom_components/custom_components.py +1 -2
  214. reflex/event.py +58 -60
  215. reflex/experimental/__init__.py +2 -2
  216. reflex/experimental/client_state.py +9 -4
  217. reflex/experimental/layout.pyi +0 -5
  218. reflex/istate/manager.py +15 -19
  219. reflex/istate/proxy.py +19 -12
  220. reflex/model.py +6 -4
  221. reflex/plugins/base.py +8 -0
  222. reflex/plugins/tailwind_v3.py +8 -0
  223. reflex/plugins/tailwind_v4.py +8 -0
  224. reflex/reflex.py +9 -11
  225. reflex/route.py +7 -9
  226. reflex/state.py +66 -70
  227. reflex/style.py +3 -1
  228. reflex/testing.py +46 -29
  229. reflex/utils/build.py +2 -1
  230. reflex/utils/console.py +9 -17
  231. reflex/utils/exec.py +9 -11
  232. reflex/utils/format.py +21 -24
  233. reflex/utils/imports.py +4 -3
  234. reflex/utils/lazy_loader.py +3 -3
  235. reflex/utils/misc.py +2 -1
  236. reflex/utils/net.py +2 -2
  237. reflex/utils/path_ops.py +2 -1
  238. reflex/utils/prerequisites.py +67 -38
  239. reflex/utils/processes.py +4 -6
  240. reflex/utils/pyi_generator.py +46 -41
  241. reflex/utils/redir.py +1 -1
  242. reflex/utils/serializers.py +4 -4
  243. reflex/utils/telemetry.py +42 -4
  244. reflex/utils/types.py +16 -13
  245. reflex/vars/base.py +96 -109
  246. reflex/vars/datetime.py +2 -1
  247. reflex/vars/dep_tracking.py +19 -28
  248. reflex/vars/number.py +6 -7
  249. reflex/vars/object.py +5 -6
  250. reflex/vars/sequence.py +11 -11
  251. {reflex-0.7.13a2.dist-info → reflex-0.7.14a1.dist-info}/METADATA +1 -1
  252. reflex-0.7.14a1.dist-info/RECORD +407 -0
  253. reflex-0.7.13a2.dist-info/RECORD +0 -407
  254. {reflex-0.7.13a2.dist-info → reflex-0.7.14a1.dist-info}/WHEEL +0 -0
  255. {reflex-0.7.13a2.dist-info → reflex-0.7.14a1.dist-info}/entry_points.txt +0 -0
  256. {reflex-0.7.13a2.dist-info → reflex-0.7.14a1.dist-info}/licenses/LICENSE +0 -0
@@ -73,7 +73,7 @@ class DependencyTracker:
73
73
  self.func = cast(FunctionType, self.func.func) # pyright: ignore[reportAttributeAccessIssue]
74
74
  with contextlib.suppress(AttributeError):
75
75
  # unbox EventHandler
76
- self.func = cast(FunctionType, self.func.fn) # pyright: ignore[reportAttributeAccessIssue]
76
+ self.func = cast(FunctionType, self.func.fn) # pyright: ignore[reportAttributeAccessIssue,reportFunctionMemberAccess]
77
77
 
78
78
  if isinstance(self.func, FunctionType):
79
79
  with contextlib.suppress(AttributeError, IndexError):
@@ -106,9 +106,8 @@ class DependencyTracker:
106
106
  from .base import ComputedVar
107
107
 
108
108
  if instruction.argval in self.INVALID_NAMES:
109
- raise VarValueError(
110
- f"Cached var {self!s} cannot access arbitrary state via `{instruction.argval}`."
111
- )
109
+ msg = f"Cached var {self!s} cannot access arbitrary state via `{instruction.argval}`."
110
+ raise VarValueError(msg)
112
111
  if instruction.argval == "get_state":
113
112
  # Special case: arbitrary state access requested.
114
113
  self.scan_status = ScanStatus.GETTING_STATE
@@ -193,37 +192,32 @@ class DependencyTracker:
193
192
  from reflex.state import BaseState
194
193
 
195
194
  if instruction.opname == "LOAD_FAST":
196
- raise VarValueError(
197
- f"Dependency detection cannot identify get_state class from local var {instruction.argval}."
198
- )
195
+ msg = f"Dependency detection cannot identify get_state class from local var {instruction.argval}."
196
+ raise VarValueError(msg)
199
197
  if isinstance(self.func, CodeType):
200
- raise VarValueError(
201
- "Dependency detection cannot identify get_state class from a code object."
202
- )
198
+ msg = "Dependency detection cannot identify get_state class from a code object."
199
+ raise VarValueError(msg)
203
200
  if instruction.opname == "LOAD_GLOBAL":
204
201
  # Special case: referencing state class from global scope.
205
202
  try:
206
203
  self._getting_state_class = self._get_globals()[instruction.argval]
207
204
  except (ValueError, KeyError) as ve:
208
- raise VarValueError(
209
- f"Cached var {self!s} cannot access arbitrary state `{instruction.argval}`, not found in globals."
210
- ) from ve
205
+ msg = f"Cached var {self!s} cannot access arbitrary state `{instruction.argval}`, not found in globals."
206
+ raise VarValueError(msg) from ve
211
207
  elif instruction.opname == "LOAD_DEREF":
212
208
  # Special case: referencing state class from closure.
213
209
  try:
214
210
  self._getting_state_class = self._get_closure()[instruction.argval]
215
211
  except (ValueError, KeyError) as ve:
216
- raise VarValueError(
217
- f"Cached var {self!s} cannot access arbitrary state `{instruction.argval}`, is it defined yet?"
218
- ) from ve
212
+ msg = f"Cached var {self!s} cannot access arbitrary state `{instruction.argval}`, is it defined yet?"
213
+ raise VarValueError(msg) from ve
219
214
  elif instruction.opname == "STORE_FAST":
220
215
  # Storing the result of get_state in a local variable.
221
216
  if not isinstance(self._getting_state_class, type) or not issubclass(
222
217
  self._getting_state_class, BaseState
223
218
  ):
224
- raise VarValueError(
225
- f"Cached var {self!s} cannot determine dependencies in fetched state `{instruction.argval}`."
226
- )
219
+ msg = f"Cached var {self!s} cannot determine dependencies in fetched state `{instruction.argval}`."
220
+ raise VarValueError(msg)
227
221
  self.tracked_locals[instruction.argval] = self._getting_state_class
228
222
  self.scan_status = ScanStatus.SCANNING
229
223
  self._getting_state_class = None
@@ -242,9 +236,8 @@ class DependencyTracker:
242
236
  positions0 = self._getting_var_instructions[0].positions
243
237
  positions1 = self._getting_var_instructions[-1].positions
244
238
  if module is None or positions0 is None or positions1 is None:
245
- raise VarValueError(
246
- f"Cannot determine the source code for the var in {self.func!r}."
247
- )
239
+ msg = f"Cannot determine the source code for the var in {self.func!r}."
240
+ raise VarValueError(msg)
248
241
  start_line = positions0.lineno
249
242
  start_column = positions0.col_offset
250
243
  end_line = positions1.end_lineno
@@ -255,9 +248,8 @@ class DependencyTracker:
255
248
  or end_line is None
256
249
  or end_column is None
257
250
  ):
258
- raise VarValueError(
259
- f"Cannot determine the source code for the var in {self.func!r}."
260
- )
251
+ msg = f"Cannot determine the source code for the var in {self.func!r}."
252
+ raise VarValueError(msg)
261
253
  source = inspect.getsource(module).splitlines(True)[start_line - 1 : end_line]
262
254
  # Create a python source string snippet.
263
255
  if len(source) > 1:
@@ -292,9 +284,8 @@ class DependencyTracker:
292
284
  the_var = self._eval_var()
293
285
  the_var_data = the_var._get_all_var_data()
294
286
  if the_var_data is None:
295
- raise VarValueError(
296
- f"Cannot determine the source code for the var in {self.func!r}."
297
- )
287
+ msg = f"Cannot determine the source code for the var in {self.func!r}."
288
+ raise VarValueError(msg)
298
289
  self.dependencies.setdefault(the_var_data.state, set()).add(
299
290
  the_var_data.field_name
300
291
  )
reflex/vars/number.py CHANGED
@@ -53,9 +53,8 @@ def raise_unsupported_operand_types(
53
53
  Raises:
54
54
  VarTypeError: The operand types are unsupported.
55
55
  """
56
- raise VarTypeError(
57
- f"Unsupported Operand type(s) for {operator}: {', '.join(t.__name__ for t in operands_types)}"
58
- )
56
+ msg = f"Unsupported Operand type(s) for {operator}: {', '.join(t.__name__ for t in operands_types)}"
57
+ raise VarTypeError(msg)
59
58
 
60
59
 
61
60
  class NumberVar(Var[NUMBER_T], python_types=(int, float, decimal.Decimal)):
@@ -486,10 +485,11 @@ class NumberVar(Var[NUMBER_T], python_types=(int, float, decimal.Decimal)):
486
485
  )
487
486
 
488
487
  if format_spec:
489
- raise VarValueError(
488
+ msg = (
490
489
  f"Unknown format code '{format_spec}' for object of type 'NumberVar'. It is only supported to use ',', '_', and '.f' for float numbers."
491
490
  "If possible, use computed variables instead: https://reflex.dev/docs/vars/computed-vars/"
492
491
  )
492
+ raise VarValueError(msg)
493
493
 
494
494
  return super().__format__(format_spec)
495
495
 
@@ -961,9 +961,8 @@ class LiteralNumberVar(LiteralVar, NumberVar[NUMBER_T]):
961
961
  if isinstance(self._var_value, decimal.Decimal):
962
962
  return json.dumps(float(self._var_value))
963
963
  if math.isinf(self._var_value) or math.isnan(self._var_value):
964
- raise PrimitiveUnserializableToJSONError(
965
- f"No valid JSON representation for {self}"
966
- )
964
+ msg = f"No valid JSON representation for {self}"
965
+ raise PrimitiveUnserializableToJSONError(msg)
967
966
  return json.dumps(self._var_value)
968
967
 
969
968
  def __hash__(self) -> int:
reflex/vars/object.py CHANGED
@@ -333,13 +333,13 @@ class ObjectVar(Var[OBJECT_TYPE], python_types=Mapping):
333
333
  ):
334
334
  attribute_type = get_attribute_access_type(var_type, name)
335
335
  if attribute_type is None:
336
- raise VarAttributeError(
336
+ msg = (
337
337
  f"The State var `{self!s}` of type {escape(str(self._var_type))} has no attribute '{name}' or may have been annotated "
338
338
  f"wrongly."
339
339
  )
340
+ raise VarAttributeError(msg)
340
341
  return ObjectItemOperation.create(self, name, attribute_type).guess_type()
341
- else:
342
- return ObjectItemOperation.create(self, name).guess_type()
342
+ return ObjectItemOperation.create(self, name).guess_type()
343
343
 
344
344
  def contains(self, key: Var | Any) -> BooleanVar:
345
345
  """Check if the object contains a key.
@@ -413,9 +413,8 @@ class LiteralObjectVar(CachedVarOperation, ObjectVar[OBJECT_TYPE], LiteralVar):
413
413
  key = LiteralVar.create(key)
414
414
  value = LiteralVar.create(value)
415
415
  if not isinstance(key, LiteralVar) or not isinstance(value, LiteralVar):
416
- raise TypeError(
417
- "The keys and values of the object must be literal vars to get the JSON representation."
418
- )
416
+ msg = "The keys and values of the object must be literal vars to get the JSON representation."
417
+ raise TypeError(msg)
419
418
  keys_and_values.append(f"{key.json()}:{value.json()}")
420
419
  return "{" + ", ".join(keys_and_values) + "}"
421
420
 
reflex/vars/sequence.py CHANGED
@@ -445,9 +445,8 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
445
445
  # get the number of arguments of the function
446
446
  num_args = len(inspect.signature(fn).parameters)
447
447
  if num_args > 1:
448
- raise VarTypeError(
449
- "The function passed to foreach should take at most one argument."
450
- )
448
+ msg = "The function passed to foreach should take at most one argument."
449
+ raise VarTypeError(msg)
451
450
 
452
451
  if num_args == 0:
453
452
  return_value = fn()
@@ -535,9 +534,8 @@ class LiteralArrayVar(CachedVarOperation, LiteralVar, ArrayVar[ARRAY_VAR_TYPE]):
535
534
  for element in self._var_value:
536
535
  element_var = LiteralVar.create(element)
537
536
  if not isinstance(element_var, LiteralVar):
538
- raise TypeError(
539
- f"Array elements must be of type LiteralVar, not {type(element_var)}"
540
- )
537
+ msg = f"Array elements must be of type LiteralVar, not {type(element_var)}"
538
+ raise TypeError(msg)
541
539
  elements.append(element_var.json())
542
540
 
543
541
  return "[" + ", ".join(elements) + "]"
@@ -1203,8 +1201,7 @@ class LiteralStringVar(LiteralVar, StringVar[str]):
1203
1201
  only_string = filtered_strings_and_vals[0]
1204
1202
  if isinstance(only_string, str):
1205
1203
  return LiteralVar.create(only_string).to(StringVar, _var_type)
1206
- else:
1207
- return only_string.to(StringVar, only_string._var_type)
1204
+ return only_string.to(StringVar, only_string._var_type)
1208
1205
 
1209
1206
  if len(
1210
1207
  literal_strings := [
@@ -1400,7 +1397,8 @@ class ArraySliceOperation(CachedVarOperation, ArrayVar):
1400
1397
  actual_end = start + 1 if start is not None else self._array.length()
1401
1398
  return str(self._array[actual_start:actual_end].reverse()[::-step])
1402
1399
  if step == 0:
1403
- raise ValueError("slice step cannot be zero")
1400
+ msg = "slice step cannot be zero"
1401
+ raise ValueError(msg)
1404
1402
  return f"{self._array!s}.slice({normalized_start!s}, {normalized_end!s}).filter((_, i) => i % {step!s} === 0)"
1405
1403
 
1406
1404
  actual_start_reverse = end + 1 if end is not None else 0
@@ -1866,13 +1864,15 @@ class LiteralColorVar(CachedVarOperation, LiteralVar, ColorVar):
1866
1864
  (self._var_value.color, self._var_value.alpha, self._var_value.shade),
1867
1865
  )
1868
1866
  if color is None or alpha is None or shade is None:
1869
- raise TypeError("Cannot serialize color that contains non-literal vars.")
1867
+ msg = "Cannot serialize color that contains non-literal vars."
1868
+ raise TypeError(msg)
1870
1869
  if (
1871
1870
  not isinstance(color, str)
1872
1871
  or not isinstance(alpha, bool)
1873
1872
  or not isinstance(shade, int)
1874
1873
  ):
1875
- raise TypeError("Color is not a valid color.")
1874
+ msg = "Color is not a valid color."
1875
+ raise TypeError(msg)
1876
1876
  return f"var(--{color}-{'a' if alpha else ''}{shade})"
1877
1877
 
1878
1878
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reflex
3
- Version: 0.7.13a2
3
+ Version: 0.7.14a1
4
4
  Summary: Web apps in pure Python.
5
5
  Project-URL: homepage, https://reflex.dev
6
6
  Project-URL: repository, https://github.com/reflex-dev/reflex