reflex 0.7.7a2__py3-none-any.whl → 0.7.8__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 (185) hide show
  1. reflex/.templates/web/utils/state.js +26 -16
  2. reflex/admin.py +1 -1
  3. reflex/app.py +6 -17
  4. reflex/app_mixins/lifespan.py +1 -1
  5. reflex/base.py +2 -2
  6. reflex/compiler/compiler.py +8 -7
  7. reflex/compiler/utils.py +6 -5
  8. reflex/components/base/app_wrap.pyi +18 -17
  9. reflex/components/base/bare.py +2 -1
  10. reflex/components/base/body.pyi +18 -17
  11. reflex/components/base/document.pyi +82 -81
  12. reflex/components/base/error_boundary.pyi +19 -18
  13. reflex/components/base/fragment.pyi +18 -17
  14. reflex/components/base/head.pyi +34 -33
  15. reflex/components/base/link.pyi +34 -33
  16. reflex/components/base/meta.pyi +66 -65
  17. reflex/components/base/script.pyi +21 -20
  18. reflex/components/base/strict_mode.pyi +18 -17
  19. reflex/components/component.py +20 -36
  20. reflex/components/core/auto_scroll.pyi +18 -17
  21. reflex/components/core/banner.pyi +98 -97
  22. reflex/components/core/breakpoints.py +1 -1
  23. reflex/components/core/client_side_routing.pyi +34 -33
  24. reflex/components/core/clipboard.py +1 -1
  25. reflex/components/core/clipboard.pyi +19 -18
  26. reflex/components/core/cond.py +2 -2
  27. reflex/components/core/debounce.py +3 -3
  28. reflex/components/core/debounce.pyi +20 -19
  29. reflex/components/core/foreach.py +2 -1
  30. reflex/components/core/html.pyi +18 -17
  31. reflex/components/core/match.py +2 -2
  32. reflex/components/core/sticky.pyi +66 -65
  33. reflex/components/core/upload.py +7 -10
  34. reflex/components/core/upload.pyi +86 -85
  35. reflex/components/datadisplay/code.pyi +34 -33
  36. reflex/components/datadisplay/dataeditor.py +3 -2
  37. reflex/components/datadisplay/dataeditor.pyi +35 -68
  38. reflex/components/datadisplay/shiki_code_block.pyi +50 -49
  39. reflex/components/el/element.pyi +18 -17
  40. reflex/components/el/elements/base.pyi +18 -17
  41. reflex/components/el/elements/forms.py +2 -1
  42. reflex/components/el/elements/forms.pyi +290 -332
  43. reflex/components/el/elements/inline.pyi +450 -449
  44. reflex/components/el/elements/media.pyi +402 -401
  45. reflex/components/el/elements/metadata.pyi +98 -97
  46. reflex/components/el/elements/other.pyi +114 -113
  47. reflex/components/el/elements/scripts.pyi +50 -49
  48. reflex/components/el/elements/sectioning.pyi +242 -241
  49. reflex/components/el/elements/tables.pyi +162 -161
  50. reflex/components/el/elements/typography.pyi +242 -241
  51. reflex/components/gridjs/datatable.py +3 -2
  52. reflex/components/gridjs/datatable.pyi +35 -34
  53. reflex/components/lucide/icon.pyi +50 -49
  54. reflex/components/markdown/markdown.py +2 -1
  55. reflex/components/markdown/markdown.pyi +18 -17
  56. reflex/components/moment/moment.pyi +19 -18
  57. reflex/components/next/base.pyi +18 -17
  58. reflex/components/next/image.pyi +20 -19
  59. reflex/components/next/link.pyi +18 -17
  60. reflex/components/next/video.pyi +18 -17
  61. reflex/components/plotly/plotly.py +3 -3
  62. reflex/components/plotly/plotly.pyi +326 -325
  63. reflex/components/radix/primitives/accordion.py +2 -1
  64. reflex/components/radix/primitives/accordion.pyi +115 -114
  65. reflex/components/radix/primitives/base.pyi +34 -33
  66. reflex/components/radix/primitives/drawer.py +2 -1
  67. reflex/components/radix/primitives/drawer.pyi +187 -186
  68. reflex/components/radix/primitives/form.pyi +168 -182
  69. reflex/components/radix/primitives/progress.pyi +82 -81
  70. reflex/components/radix/primitives/slider.py +2 -1
  71. reflex/components/radix/primitives/slider.pyi +84 -83
  72. reflex/components/radix/themes/base.pyi +130 -129
  73. reflex/components/radix/themes/color_mode.pyi +51 -50
  74. reflex/components/radix/themes/components/alert_dialog.pyi +118 -117
  75. reflex/components/radix/themes/components/aspect_ratio.pyi +18 -17
  76. reflex/components/radix/themes/components/avatar.pyi +18 -17
  77. reflex/components/radix/themes/components/badge.pyi +18 -17
  78. reflex/components/radix/themes/components/button.pyi +18 -17
  79. reflex/components/radix/themes/components/callout.pyi +82 -81
  80. reflex/components/radix/themes/components/card.pyi +18 -17
  81. reflex/components/radix/themes/components/checkbox.pyi +53 -52
  82. reflex/components/radix/themes/components/checkbox_cards.pyi +34 -33
  83. reflex/components/radix/themes/components/checkbox_group.py +2 -1
  84. reflex/components/radix/themes/components/checkbox_group.pyi +34 -33
  85. reflex/components/radix/themes/components/context_menu.pyi +225 -224
  86. reflex/components/radix/themes/components/data_list.pyi +66 -65
  87. reflex/components/radix/themes/components/dialog.pyi +121 -120
  88. reflex/components/radix/themes/components/dropdown_menu.pyi +142 -141
  89. reflex/components/radix/themes/components/hover_card.pyi +68 -67
  90. reflex/components/radix/themes/components/icon_button.pyi +18 -17
  91. reflex/components/radix/themes/components/inset.pyi +18 -17
  92. reflex/components/radix/themes/components/popover.pyi +73 -72
  93. reflex/components/radix/themes/components/progress.pyi +18 -17
  94. reflex/components/radix/themes/components/radio.pyi +18 -17
  95. reflex/components/radix/themes/components/radio_cards.pyi +35 -34
  96. reflex/components/radix/themes/components/radio_group.py +2 -1
  97. reflex/components/radix/themes/components/radio_group.pyi +67 -66
  98. reflex/components/radix/themes/components/scroll_area.pyi +18 -17
  99. reflex/components/radix/themes/components/segmented_control.py +2 -1
  100. reflex/components/radix/themes/components/segmented_control.pyi +35 -34
  101. reflex/components/radix/themes/components/select.py +2 -1
  102. reflex/components/radix/themes/components/select.pyi +155 -154
  103. reflex/components/radix/themes/components/separator.pyi +18 -17
  104. reflex/components/radix/themes/components/skeleton.pyi +18 -17
  105. reflex/components/radix/themes/components/slider.py +2 -1
  106. reflex/components/radix/themes/components/slider.pyi +20 -31
  107. reflex/components/radix/themes/components/spinner.pyi +18 -17
  108. reflex/components/radix/themes/components/switch.pyi +19 -18
  109. reflex/components/radix/themes/components/table.pyi +114 -113
  110. reflex/components/radix/themes/components/tabs.pyi +84 -83
  111. reflex/components/radix/themes/components/text_area.pyi +21 -24
  112. reflex/components/radix/themes/components/text_field.pyi +56 -63
  113. reflex/components/radix/themes/components/tooltip.py +2 -2
  114. reflex/components/radix/themes/components/tooltip.pyi +21 -20
  115. reflex/components/radix/themes/layout/base.pyi +18 -17
  116. reflex/components/radix/themes/layout/box.pyi +18 -17
  117. reflex/components/radix/themes/layout/center.pyi +18 -17
  118. reflex/components/radix/themes/layout/container.pyi +18 -17
  119. reflex/components/radix/themes/layout/flex.pyi +18 -17
  120. reflex/components/radix/themes/layout/grid.pyi +18 -17
  121. reflex/components/radix/themes/layout/list.py +2 -1
  122. reflex/components/radix/themes/layout/list.pyi +82 -81
  123. reflex/components/radix/themes/layout/section.pyi +18 -17
  124. reflex/components/radix/themes/layout/spacer.pyi +18 -17
  125. reflex/components/radix/themes/layout/stack.pyi +50 -49
  126. reflex/components/radix/themes/typography/blockquote.pyi +18 -17
  127. reflex/components/radix/themes/typography/code.pyi +18 -17
  128. reflex/components/radix/themes/typography/heading.pyi +18 -17
  129. reflex/components/radix/themes/typography/link.pyi +18 -17
  130. reflex/components/radix/themes/typography/text.pyi +114 -113
  131. reflex/components/react_player/audio.pyi +34 -36
  132. reflex/components/react_player/react_player.pyi +34 -33
  133. reflex/components/react_player/video.pyi +34 -36
  134. reflex/components/recharts/cartesian.py +7 -6
  135. reflex/components/recharts/cartesian.pyi +302 -301
  136. reflex/components/recharts/charts.py +2 -1
  137. reflex/components/recharts/charts.pyi +177 -176
  138. reflex/components/recharts/general.py +3 -2
  139. reflex/components/recharts/general.pyi +99 -98
  140. reflex/components/recharts/polar.py +9 -8
  141. reflex/components/recharts/polar.pyi +62 -61
  142. reflex/components/recharts/recharts.pyi +34 -33
  143. reflex/components/sonner/toast.pyi +19 -18
  144. reflex/components/suneditor/editor.py +22 -24
  145. reflex/components/suneditor/editor.pyi +27 -28
  146. reflex/components/tags/cond_tag.py +3 -3
  147. reflex/components/tags/iter_tag.py +2 -1
  148. reflex/components/tags/tag.py +3 -2
  149. reflex/config.py +27 -17
  150. reflex/constants/installer.py +4 -4
  151. reflex/constants/route.py +2 -3
  152. reflex/constants/utils.py +4 -3
  153. reflex/event.py +56 -28
  154. reflex/experimental/client_state.py +3 -2
  155. reflex/experimental/layout.pyi +84 -83
  156. reflex/istate/data.py +1 -1
  157. reflex/istate/storage.py +2 -2
  158. reflex/model.py +3 -3
  159. reflex/page.py +3 -2
  160. reflex/state.py +56 -57
  161. reflex/style.py +3 -2
  162. reflex/testing.py +12 -21
  163. reflex/utils/codespaces.py +14 -15
  164. reflex/utils/decorator.py +2 -1
  165. reflex/utils/exec.py +1 -1
  166. reflex/utils/format.py +2 -2
  167. reflex/utils/imports.py +6 -8
  168. reflex/utils/misc.py +2 -1
  169. reflex/utils/net.py +2 -1
  170. reflex/utils/prerequisites.py +12 -5
  171. reflex/utils/processes.py +6 -5
  172. reflex/utils/pyi_generator.py +6 -5
  173. reflex/utils/serializers.py +13 -25
  174. reflex/utils/types.py +34 -46
  175. reflex/vars/base.py +60 -56
  176. reflex/vars/dep_tracking.py +4 -4
  177. reflex/vars/function.py +13 -36
  178. reflex/vars/number.py +5 -17
  179. reflex/vars/object.py +9 -16
  180. reflex/vars/sequence.py +11 -23
  181. {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/METADATA +1 -1
  182. {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/RECORD +185 -185
  183. {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/WHEEL +0 -0
  184. {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/entry_points.txt +0 -0
  185. {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/licenses/LICENSE +0 -0
@@ -3,7 +3,8 @@
3
3
  # ------------------- DO NOT EDIT ----------------------
4
4
  # This file was generated by `reflex/utils/pyi_generator.py`!
5
5
  # ------------------------------------------------------
6
- from typing import Any, Literal, Mapping, Optional, Sequence, overload
6
+ from collections.abc import Mapping, Sequence
7
+ from typing import Any, Literal, overload
7
8
 
8
9
  from reflex import color
9
10
  from reflex.components.base.fragment import Fragment
@@ -209,23 +210,23 @@ class Sidebar(Box, MemoizationLeaf):
209
210
  class_name: Any | None = None,
210
211
  autofocus: bool | None = None,
211
212
  custom_attrs: dict[str, Var | Any] | None = None,
212
- on_blur: Optional[EventType[()]] = None,
213
- on_click: Optional[EventType[()]] = None,
214
- on_context_menu: Optional[EventType[()]] = None,
215
- on_double_click: Optional[EventType[()]] = None,
216
- on_focus: Optional[EventType[()]] = None,
217
- on_mount: Optional[EventType[()]] = None,
218
- on_mouse_down: Optional[EventType[()]] = None,
219
- on_mouse_enter: Optional[EventType[()]] = None,
220
- on_mouse_leave: Optional[EventType[()]] = None,
221
- on_mouse_move: Optional[EventType[()]] = None,
222
- on_mouse_out: Optional[EventType[()]] = None,
223
- on_mouse_over: Optional[EventType[()]] = None,
224
- on_mouse_up: Optional[EventType[()]] = None,
225
- on_scroll: Optional[EventType[()]] = None,
226
- on_unmount: Optional[EventType[()]] = None,
213
+ on_blur: EventType[()] | None = None,
214
+ on_click: EventType[()] | None = None,
215
+ on_context_menu: EventType[()] | None = None,
216
+ on_double_click: EventType[()] | None = None,
217
+ on_focus: EventType[()] | None = None,
218
+ on_mount: EventType[()] | None = None,
219
+ on_mouse_down: EventType[()] | None = None,
220
+ on_mouse_enter: EventType[()] | None = None,
221
+ on_mouse_leave: EventType[()] | None = None,
222
+ on_mouse_move: EventType[()] | None = None,
223
+ on_mouse_out: EventType[()] | None = None,
224
+ on_mouse_over: EventType[()] | None = None,
225
+ on_mouse_up: EventType[()] | None = None,
226
+ on_scroll: EventType[()] | None = None,
227
+ on_unmount: EventType[()] | None = None,
227
228
  **props,
228
- ) -> "Sidebar":
229
+ ) -> Sidebar:
229
230
  """Create the sidebar component.
230
231
 
231
232
  Args:
@@ -278,25 +279,25 @@ class DrawerSidebar(DrawerRoot):
278
279
  class_name: Any | None = None,
279
280
  autofocus: bool | None = None,
280
281
  custom_attrs: dict[str, Var | Any] | None = None,
281
- on_animation_end: Optional[EventType[()] | EventType[bool]] = None,
282
- on_blur: Optional[EventType[()]] = None,
283
- on_click: Optional[EventType[()]] = None,
284
- on_context_menu: Optional[EventType[()]] = None,
285
- on_double_click: Optional[EventType[()]] = None,
286
- on_focus: Optional[EventType[()]] = None,
287
- on_mount: Optional[EventType[()]] = None,
288
- on_mouse_down: Optional[EventType[()]] = None,
289
- on_mouse_enter: Optional[EventType[()]] = None,
290
- on_mouse_leave: Optional[EventType[()]] = None,
291
- on_mouse_move: Optional[EventType[()]] = None,
292
- on_mouse_out: Optional[EventType[()]] = None,
293
- on_mouse_over: Optional[EventType[()]] = None,
294
- on_mouse_up: Optional[EventType[()]] = None,
295
- on_open_change: Optional[EventType[()] | EventType[bool]] = None,
296
- on_scroll: Optional[EventType[()]] = None,
297
- on_unmount: Optional[EventType[()]] = None,
282
+ on_animation_end: EventType[()] | EventType[bool] | None = None,
283
+ on_blur: EventType[()] | None = None,
284
+ on_click: EventType[()] | None = None,
285
+ on_context_menu: EventType[()] | None = None,
286
+ on_double_click: EventType[()] | None = None,
287
+ on_focus: EventType[()] | None = None,
288
+ on_mount: EventType[()] | None = None,
289
+ on_mouse_down: EventType[()] | None = None,
290
+ on_mouse_enter: EventType[()] | None = None,
291
+ on_mouse_leave: EventType[()] | None = None,
292
+ on_mouse_move: EventType[()] | None = None,
293
+ on_mouse_out: EventType[()] | None = None,
294
+ on_mouse_over: EventType[()] | None = None,
295
+ on_mouse_up: EventType[()] | None = None,
296
+ on_open_change: EventType[()] | EventType[bool] | None = None,
297
+ on_scroll: EventType[()] | None = None,
298
+ on_unmount: EventType[()] | None = None,
298
299
  **props,
299
- ) -> "DrawerSidebar":
300
+ ) -> DrawerSidebar:
300
301
  """Create the sidebar component.
301
302
 
302
303
  Args:
@@ -332,23 +333,23 @@ class SidebarTrigger(Fragment):
332
333
  class_name: Any | None = None,
333
334
  autofocus: bool | None = None,
334
335
  custom_attrs: dict[str, Var | Any] | None = None,
335
- on_blur: Optional[EventType[()]] = None,
336
- on_click: Optional[EventType[()]] = None,
337
- on_context_menu: Optional[EventType[()]] = None,
338
- on_double_click: Optional[EventType[()]] = None,
339
- on_focus: Optional[EventType[()]] = None,
340
- on_mount: Optional[EventType[()]] = None,
341
- on_mouse_down: Optional[EventType[()]] = None,
342
- on_mouse_enter: Optional[EventType[()]] = None,
343
- on_mouse_leave: Optional[EventType[()]] = None,
344
- on_mouse_move: Optional[EventType[()]] = None,
345
- on_mouse_out: Optional[EventType[()]] = None,
346
- on_mouse_over: Optional[EventType[()]] = None,
347
- on_mouse_up: Optional[EventType[()]] = None,
348
- on_scroll: Optional[EventType[()]] = None,
349
- on_unmount: Optional[EventType[()]] = None,
336
+ on_blur: EventType[()] | None = None,
337
+ on_click: EventType[()] | None = None,
338
+ on_context_menu: EventType[()] | None = None,
339
+ on_double_click: EventType[()] | None = None,
340
+ on_focus: EventType[()] | None = None,
341
+ on_mount: EventType[()] | None = None,
342
+ on_mouse_down: EventType[()] | None = None,
343
+ on_mouse_enter: EventType[()] | None = None,
344
+ on_mouse_leave: EventType[()] | None = None,
345
+ on_mouse_move: EventType[()] | None = None,
346
+ on_mouse_out: EventType[()] | None = None,
347
+ on_mouse_over: EventType[()] | None = None,
348
+ on_mouse_up: EventType[()] | None = None,
349
+ on_scroll: EventType[()] | None = None,
350
+ on_unmount: EventType[()] | None = None,
350
351
  **props,
351
- ) -> "SidebarTrigger":
352
+ ) -> SidebarTrigger:
352
353
  """Create the sidebar trigger component.
353
354
 
354
355
  Args:
@@ -555,23 +556,23 @@ class Layout(Box):
555
556
  class_name: Any | None = None,
556
557
  autofocus: bool | None = None,
557
558
  custom_attrs: dict[str, Var | Any] | None = None,
558
- on_blur: Optional[EventType[()]] = None,
559
- on_click: Optional[EventType[()]] = None,
560
- on_context_menu: Optional[EventType[()]] = None,
561
- on_double_click: Optional[EventType[()]] = None,
562
- on_focus: Optional[EventType[()]] = None,
563
- on_mount: Optional[EventType[()]] = None,
564
- on_mouse_down: Optional[EventType[()]] = None,
565
- on_mouse_enter: Optional[EventType[()]] = None,
566
- on_mouse_leave: Optional[EventType[()]] = None,
567
- on_mouse_move: Optional[EventType[()]] = None,
568
- on_mouse_out: Optional[EventType[()]] = None,
569
- on_mouse_over: Optional[EventType[()]] = None,
570
- on_mouse_up: Optional[EventType[()]] = None,
571
- on_scroll: Optional[EventType[()]] = None,
572
- on_unmount: Optional[EventType[()]] = None,
559
+ on_blur: EventType[()] | None = None,
560
+ on_click: EventType[()] | None = None,
561
+ on_context_menu: EventType[()] | None = None,
562
+ on_double_click: EventType[()] | None = None,
563
+ on_focus: EventType[()] | None = None,
564
+ on_mount: EventType[()] | None = None,
565
+ on_mouse_down: EventType[()] | None = None,
566
+ on_mouse_enter: EventType[()] | None = None,
567
+ on_mouse_leave: EventType[()] | None = None,
568
+ on_mouse_move: EventType[()] | None = None,
569
+ on_mouse_out: EventType[()] | None = None,
570
+ on_mouse_over: EventType[()] | None = None,
571
+ on_mouse_up: EventType[()] | None = None,
572
+ on_scroll: EventType[()] | None = None,
573
+ on_unmount: EventType[()] | None = None,
573
574
  **props,
574
- ) -> "Layout":
575
+ ) -> Layout:
575
576
  """Create the layout component.
576
577
 
577
578
  Args:
@@ -781,23 +782,23 @@ class LayoutNamespace(ComponentNamespace):
781
782
  class_name: Any | None = None,
782
783
  autofocus: bool | None = None,
783
784
  custom_attrs: dict[str, Var | Any] | None = None,
784
- on_blur: Optional[EventType[()]] = None,
785
- on_click: Optional[EventType[()]] = None,
786
- on_context_menu: Optional[EventType[()]] = None,
787
- on_double_click: Optional[EventType[()]] = None,
788
- on_focus: Optional[EventType[()]] = None,
789
- on_mount: Optional[EventType[()]] = None,
790
- on_mouse_down: Optional[EventType[()]] = None,
791
- on_mouse_enter: Optional[EventType[()]] = None,
792
- on_mouse_leave: Optional[EventType[()]] = None,
793
- on_mouse_move: Optional[EventType[()]] = None,
794
- on_mouse_out: Optional[EventType[()]] = None,
795
- on_mouse_over: Optional[EventType[()]] = None,
796
- on_mouse_up: Optional[EventType[()]] = None,
797
- on_scroll: Optional[EventType[()]] = None,
798
- on_unmount: Optional[EventType[()]] = None,
785
+ on_blur: EventType[()] | None = None,
786
+ on_click: EventType[()] | None = None,
787
+ on_context_menu: EventType[()] | None = None,
788
+ on_double_click: EventType[()] | None = None,
789
+ on_focus: EventType[()] | None = None,
790
+ on_mount: EventType[()] | None = None,
791
+ on_mouse_down: EventType[()] | None = None,
792
+ on_mouse_enter: EventType[()] | None = None,
793
+ on_mouse_leave: EventType[()] | None = None,
794
+ on_mouse_move: EventType[()] | None = None,
795
+ on_mouse_out: EventType[()] | None = None,
796
+ on_mouse_over: EventType[()] | None = None,
797
+ on_mouse_up: EventType[()] | None = None,
798
+ on_scroll: EventType[()] | None = None,
799
+ on_unmount: EventType[()] | None = None,
799
800
  **props,
800
- ) -> "Layout":
801
+ ) -> Layout:
801
802
  """Create the layout component.
802
803
 
803
804
  Args:
reflex/istate/data.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """This module contains the dataclasses representing the router object."""
2
2
 
3
3
  import dataclasses
4
- from typing import Mapping
4
+ from collections.abc import Mapping
5
5
 
6
6
  from reflex import constants
7
7
  from reflex.utils import format
reflex/istate/storage.py CHANGED
@@ -90,7 +90,7 @@ class LocalStorage(ClientStorageBase, str):
90
90
  /,
91
91
  name: str | None = None,
92
92
  sync: bool = False,
93
- ) -> "LocalStorage":
93
+ ) -> LocalStorage:
94
94
  """Create a client-side localStorage (str).
95
95
 
96
96
  Args:
@@ -124,7 +124,7 @@ class SessionStorage(ClientStorageBase, str):
124
124
  errors: str | None = None,
125
125
  /,
126
126
  name: str | None = None,
127
- ) -> "SessionStorage":
127
+ ) -> SessionStorage:
128
128
  """Create a client-side sessionStorage (str).
129
129
 
130
130
  Args:
reflex/model.py CHANGED
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import re
6
6
  from collections import defaultdict
7
7
  from contextlib import suppress
8
- from typing import Any, ClassVar, Type
8
+ from typing import Any, ClassVar
9
9
 
10
10
  import alembic.autogenerate
11
11
  import alembic.command
@@ -161,7 +161,7 @@ async def get_db_status() -> dict[str, bool]:
161
161
  return {"db": status}
162
162
 
163
163
 
164
- SQLModelOrSqlAlchemy = Type[sqlmodel.SQLModel] | Type[sqlalchemy.orm.DeclarativeBase]
164
+ SQLModelOrSqlAlchemy = type[sqlmodel.SQLModel] | type[sqlalchemy.orm.DeclarativeBase]
165
165
 
166
166
 
167
167
  class ModelRegistry:
@@ -328,7 +328,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
328
328
  def _alembic_render_item(
329
329
  type_: str,
330
330
  obj: Any,
331
- autogen_context: "alembic.autogenerate.api.AutogenContext",
331
+ autogen_context: alembic.autogenerate.api.AutogenContext,
332
332
  ):
333
333
  """Alembic render_item hook call.
334
334
 
reflex/page.py CHANGED
@@ -3,12 +3,13 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from collections import defaultdict
6
- from typing import Any, Callable, List
6
+ from collections.abc import Callable
7
+ from typing import Any
7
8
 
8
9
  from reflex.config import get_config
9
10
  from reflex.event import EventType
10
11
 
11
- DECORATED_PAGES: dict[str, List] = defaultdict(list)
12
+ DECORATED_PAGES: dict[str, list] = defaultdict(list)
12
13
 
13
14
 
14
15
  def page(
reflex/state.py CHANGED
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import asyncio
6
+ import builtins
6
7
  import contextlib
7
8
  import copy
8
9
  import dataclasses
@@ -16,23 +17,16 @@ import typing
16
17
  import uuid
17
18
  import warnings
18
19
  from abc import ABC, abstractmethod
20
+ from collections.abc import AsyncIterator, Callable, Sequence
19
21
  from hashlib import md5
20
22
  from pathlib import Path
21
23
  from types import FunctionType, MethodType
22
24
  from typing import (
23
25
  TYPE_CHECKING,
24
26
  Any,
25
- AsyncIterator,
26
27
  BinaryIO,
27
- Callable,
28
28
  ClassVar,
29
- Dict,
30
- Optional,
31
- Sequence,
32
- Set,
33
29
  SupportsIndex,
34
- Tuple,
35
- Type,
36
30
  TypeVar,
37
31
  cast,
38
32
  get_args,
@@ -134,7 +128,7 @@ VAR_TYPE = TypeVar("VAR_TYPE")
134
128
 
135
129
 
136
130
  def _no_chain_background_task(
137
- state_cls: Type["BaseState"], name: str, fn: Callable
131
+ state_cls: type[BaseState], name: str, fn: Callable
138
132
  ) -> Callable:
139
133
  """Protect against directly chaining a background task from another event handler.
140
134
 
@@ -173,7 +167,7 @@ def _no_chain_background_task(
173
167
 
174
168
  def _substate_key(
175
169
  token: str,
176
- state_cls_or_name: BaseState | Type[BaseState] | str | Sequence[str],
170
+ state_cls_or_name: BaseState | type[BaseState] | str | Sequence[str],
177
171
  ) -> str:
178
172
  """Get the substate key.
179
173
 
@@ -210,9 +204,9 @@ def _split_substate_key(substate_key: str) -> tuple[str, str]:
210
204
  class EventHandlerSetVar(EventHandler):
211
205
  """A special event handler to wrap setvar functionality."""
212
206
 
213
- state_cls: Type[BaseState] = dataclasses.field(init=False)
207
+ state_cls: type[BaseState] = dataclasses.field(init=False)
214
208
 
215
- def __init__(self, state_cls: Type[BaseState]):
209
+ def __init__(self, state_cls: type[BaseState]):
216
210
  """Initialize the EventHandlerSetVar.
217
211
 
218
212
  Args:
@@ -277,7 +271,7 @@ if TYPE_CHECKING:
277
271
  from pydantic.v1.fields import ModelField
278
272
 
279
273
 
280
- def _unwrap_field_type(type_: types.GenericType) -> Type:
274
+ def _unwrap_field_type(type_: types.GenericType) -> type:
281
275
  """Unwrap rx.Field type annotations.
282
276
 
283
277
  Args:
@@ -293,7 +287,7 @@ def _unwrap_field_type(type_: types.GenericType) -> Type:
293
287
  return type_
294
288
 
295
289
 
296
- def get_var_for_field(cls: Type[BaseState], f: ModelField):
290
+ def get_var_for_field(cls: type[BaseState], f: ModelField):
297
291
  """Get a Var instance for a Pydantic field.
298
292
 
299
293
  Args:
@@ -338,31 +332,31 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
338
332
  """The state of the app."""
339
333
 
340
334
  # A map from the var name to the var.
341
- vars: ClassVar[Dict[str, Var]] = {}
335
+ vars: ClassVar[builtins.dict[str, Var]] = {}
342
336
 
343
337
  # The base vars of the class.
344
- base_vars: ClassVar[Dict[str, Var]] = {}
338
+ base_vars: ClassVar[builtins.dict[str, Var]] = {}
345
339
 
346
340
  # The computed vars of the class.
347
- computed_vars: ClassVar[Dict[str, ComputedVar]] = {}
341
+ computed_vars: ClassVar[builtins.dict[str, ComputedVar]] = {}
348
342
 
349
343
  # Vars inherited by the parent state.
350
- inherited_vars: ClassVar[Dict[str, Var]] = {}
344
+ inherited_vars: ClassVar[builtins.dict[str, Var]] = {}
351
345
 
352
346
  # Backend base vars that are never sent to the client.
353
- backend_vars: ClassVar[Dict[str, Any]] = {}
347
+ backend_vars: ClassVar[builtins.dict[str, Any]] = {}
354
348
 
355
349
  # Backend base vars inherited
356
- inherited_backend_vars: ClassVar[Dict[str, Any]] = {}
350
+ inherited_backend_vars: ClassVar[builtins.dict[str, Any]] = {}
357
351
 
358
352
  # The event handlers.
359
- event_handlers: ClassVar[Dict[str, EventHandler]] = {}
353
+ event_handlers: ClassVar[builtins.dict[str, EventHandler]] = {}
360
354
 
361
355
  # A set of subclassses of this class.
362
- class_subclasses: ClassVar[set[Type[BaseState]]] = set()
356
+ class_subclasses: ClassVar[set[type[BaseState]]] = set()
363
357
 
364
358
  # Mapping of var name to set of (state_full_name, var_name) that depend on it.
365
- _var_dependencies: ClassVar[Dict[str, set[tuple[str, str]]]] = {}
359
+ _var_dependencies: ClassVar[builtins.dict[str, set[tuple[str, str]]]] = {}
366
360
 
367
361
  # Set of vars which always need to be recomputed
368
362
  _always_dirty_computed_vars: ClassVar[set[str]] = set()
@@ -377,7 +371,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
377
371
  parent_state: BaseState | None = None
378
372
 
379
373
  # The substates of the state.
380
- substates: Dict[str, BaseState] = {}
374
+ substates: builtins.dict[str, BaseState] = {}
381
375
 
382
376
  # The set of dirty vars.
383
377
  dirty_vars: set[str] = set()
@@ -386,10 +380,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
386
380
  dirty_substates: set[str] = set()
387
381
 
388
382
  # The routing path that triggered the state
389
- router_data: Dict[str, Any] = {}
383
+ router_data: builtins.dict[str, Any] = {}
390
384
 
391
385
  # Per-instance copy of backend base variable values
392
- _backend_vars: Dict[str, Any] = {}
386
+ _backend_vars: builtins.dict[str, Any] = {}
393
387
 
394
388
  # The router data for the current page
395
389
  router: RouterData = RouterData()
@@ -714,7 +708,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
714
708
  return getattr(cls, unique_var_name)
715
709
 
716
710
  @classmethod
717
- def _mixins(cls) -> list[Type]:
711
+ def _mixins(cls) -> list[type]:
718
712
  """Get the mixin classes of the state.
719
713
 
720
714
  Returns:
@@ -889,8 +883,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
889
883
  )
890
884
 
891
885
  @classmethod
892
- @functools.lru_cache()
893
- def get_parent_state(cls) -> Type[BaseState] | None:
886
+ @functools.lru_cache
887
+ def get_parent_state(cls) -> type[BaseState] | None:
894
888
  """Get the parent state.
895
889
 
896
890
  Raises:
@@ -916,8 +910,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
916
910
  return None # No known parent
917
911
 
918
912
  @classmethod
919
- @functools.lru_cache()
920
- def get_root_state(cls) -> Type[BaseState]:
913
+ @functools.lru_cache
914
+ def get_root_state(cls) -> type[BaseState]:
921
915
  """Get the root state.
922
916
 
923
917
  Returns:
@@ -927,7 +921,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
927
921
  return cls if parent_state is None else parent_state.get_root_state()
928
922
 
929
923
  @classmethod
930
- def get_substates(cls) -> set[Type[BaseState]]:
924
+ def get_substates(cls) -> set[type[BaseState]]:
931
925
  """Get the substates of the state.
932
926
 
933
927
  Returns:
@@ -936,7 +930,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
936
930
  return cls.class_subclasses
937
931
 
938
932
  @classmethod
939
- @functools.lru_cache()
933
+ @functools.lru_cache
940
934
  def get_name(cls) -> str:
941
935
  """Get the name of the state.
942
936
 
@@ -947,7 +941,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
947
941
  return format.to_snake_case(f"{module}___{cls.__name__}")
948
942
 
949
943
  @classmethod
950
- @functools.lru_cache()
944
+ @functools.lru_cache
951
945
  def get_full_name(cls) -> str:
952
946
  """Get the full name of the state.
953
947
 
@@ -961,8 +955,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
961
955
  return name
962
956
 
963
957
  @classmethod
964
- @functools.lru_cache()
965
- def get_class_substate(cls, path: Sequence[str] | str) -> Type[BaseState]:
958
+ @functools.lru_cache
959
+ def get_class_substate(cls, path: Sequence[str] | str) -> type[BaseState]:
966
960
  """Get the class substate.
967
961
 
968
962
  Args:
@@ -1133,7 +1127,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1133
1127
  and not types.is_optional(prop._var_type)
1134
1128
  ):
1135
1129
  # Ensure frontend uses null coalescing when accessing.
1136
- object.__setattr__(prop, "_var_type", Optional[prop._var_type])
1130
+ object.__setattr__(prop, "_var_type", prop._var_type | None)
1137
1131
 
1138
1132
  @classmethod
1139
1133
  def _get_var_default(cls, name: str, annotation_value: Any) -> Any:
@@ -1471,7 +1465,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1471
1465
  parent_state = parent_state.parent_state
1472
1466
  return parent_state
1473
1467
 
1474
- async def _get_state_from_redis(self, state_cls: Type[T_STATE]) -> T_STATE:
1468
+ async def _get_state_from_redis(self, state_cls: type[T_STATE]) -> T_STATE:
1475
1469
  """Get a state instance from redis.
1476
1470
 
1477
1471
  Args:
@@ -1504,7 +1498,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1504
1498
 
1505
1499
  return state_in_redis
1506
1500
 
1507
- def _get_state_from_cache(self, state_cls: Type[T_STATE]) -> T_STATE:
1501
+ def _get_state_from_cache(self, state_cls: type[T_STATE]) -> T_STATE:
1508
1502
  """Get a state instance from the cache.
1509
1503
 
1510
1504
  Args:
@@ -1524,7 +1518,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1524
1518
  )
1525
1519
  return substate
1526
1520
 
1527
- async def get_state(self, state_cls: Type[T_STATE]) -> T_STATE:
1521
+ async def get_state(self, state_cls: type[T_STATE]) -> T_STATE:
1528
1522
  """Get an instance of the state associated with this token.
1529
1523
 
1530
1524
  Allows for arbitrary access to sibling states from within an event handler.
@@ -1564,7 +1558,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1564
1558
  unset = object()
1565
1559
 
1566
1560
  # Fast case: this is a literal var and the value is known.
1567
- if (var_value := getattr(var, "_var_value", unset)) is not unset:
1561
+ if (
1562
+ var_value := getattr(var, "_var_value", unset)
1563
+ ) is not unset and not isinstance(var_value, Var):
1568
1564
  return var_value # pyright: ignore [reportReturnType]
1569
1565
 
1570
1566
  var_data = var._get_all_var_data()
@@ -1736,7 +1732,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1736
1732
  )
1737
1733
 
1738
1734
  async def _process_event(
1739
- self, handler: EventHandler, state: BaseState | StateProxy, payload: Dict
1735
+ self,
1736
+ handler: EventHandler,
1737
+ state: BaseState | StateProxy,
1738
+ payload: builtins.dict,
1740
1739
  ) -> AsyncIterator[StateUpdate]:
1741
1740
  """Process event.
1742
1741
 
@@ -1787,10 +1786,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1787
1786
  hinted_args, (Base, BaseModelV1, BaseModelV2)
1788
1787
  ):
1789
1788
  payload[arg] = hinted_args(**value)
1790
- elif isinstance(value, list) and (hinted_args is set or hinted_args is Set):
1789
+ elif isinstance(value, list) and (hinted_args is set or hinted_args is set):
1791
1790
  payload[arg] = set(value)
1792
1791
  elif isinstance(value, list) and (
1793
- hinted_args is tuple or hinted_args is Tuple
1792
+ hinted_args is tuple or hinted_args is tuple
1794
1793
  ):
1795
1794
  payload[arg] = tuple(value)
1796
1795
  elif isinstance(value, str) and (
@@ -2170,7 +2169,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
2170
2169
  _WARNED_ABOUT_STATE_SIZE.add(state_full_name)
2171
2170
 
2172
2171
  @classmethod
2173
- @functools.lru_cache()
2172
+ @functools.lru_cache
2174
2173
  def _to_schema(cls) -> str:
2175
2174
  """Convert a state to a schema.
2176
2175
 
@@ -2313,7 +2312,7 @@ def dynamic(func: Callable[[T], Component]):
2313
2312
  "You must provide a type hint for the state class in the function."
2314
2313
  )
2315
2314
 
2316
- state_class: Type[T] = values[0]
2315
+ state_class: type[T] = values[0]
2317
2316
 
2318
2317
  def wrapper() -> Component:
2319
2318
  from reflex.components.base.fragment import fragment
@@ -2465,7 +2464,7 @@ class ComponentState(State, mixin=True):
2465
2464
  super().__init_subclass__(mixin=mixin, **kwargs)
2466
2465
 
2467
2466
  @classmethod
2468
- def get_component(cls, *children, **props) -> "Component":
2467
+ def get_component(cls, *children, **props) -> Component:
2469
2468
  """Get the component instance.
2470
2469
 
2471
2470
  Args:
@@ -2480,7 +2479,7 @@ class ComponentState(State, mixin=True):
2480
2479
  )
2481
2480
 
2482
2481
  @classmethod
2483
- def create(cls, *children, **props) -> "Component":
2482
+ def create(cls, *children, **props) -> Component:
2484
2483
  """Create a new instance of the Component.
2485
2484
 
2486
2485
  Args:
@@ -2537,7 +2536,7 @@ class StateProxy(wrapt.ObjectProxy):
2537
2536
  def __init__(
2538
2537
  self,
2539
2538
  state_instance: BaseState,
2540
- parent_state_proxy: Optional["StateProxy"] = None,
2539
+ parent_state_proxy: StateProxy | None = None,
2541
2540
  ):
2542
2541
  """Create a proxy for a state instance.
2543
2542
 
@@ -2741,7 +2740,7 @@ class StateProxy(wrapt.ObjectProxy):
2741
2740
  )
2742
2741
  return self.__wrapped__.get_substate(path)
2743
2742
 
2744
- async def get_state(self, state_cls: Type[BaseState]) -> BaseState:
2743
+ async def get_state(self, state_cls: type[BaseState]) -> BaseState:
2745
2744
  """Get an instance of the state associated with this token.
2746
2745
 
2747
2746
  Args:
@@ -2808,10 +2807,10 @@ class StateManager(Base, ABC):
2808
2807
  """A class to manage many client states."""
2809
2808
 
2810
2809
  # The state class to use.
2811
- state: Type[BaseState]
2810
+ state: type[BaseState]
2812
2811
 
2813
2812
  @classmethod
2814
- def create(cls, state: Type[BaseState]):
2813
+ def create(cls, state: type[BaseState]):
2815
2814
  """Create a new state manager.
2816
2815
 
2817
2816
  Args:
@@ -3019,7 +3018,7 @@ class StateManagerDisk(StateManager):
3019
3018
  }
3020
3019
  keep_untouched = (functools.cached_property,)
3021
3020
 
3022
- def __init__(self, state: Type[BaseState]):
3021
+ def __init__(self, state: type[BaseState]):
3023
3022
  """Create a new state manager.
3024
3023
 
3025
3024
  Args:
@@ -3259,10 +3258,10 @@ class StateManagerRedis(StateManager):
3259
3258
 
3260
3259
  def _get_required_state_classes(
3261
3260
  self,
3262
- target_state_cls: Type[BaseState],
3261
+ target_state_cls: type[BaseState],
3263
3262
  subclasses: bool = False,
3264
- required_state_classes: set[Type[BaseState]] | None = None,
3265
- ) -> set[Type[BaseState]]:
3263
+ required_state_classes: set[type[BaseState]] | None = None,
3264
+ ) -> set[type[BaseState]]:
3266
3265
  """Recursively determine which states are required to fetch the target state.
3267
3266
 
3268
3267
  This will always include potentially dirty substates that depend on vars
@@ -4119,7 +4118,7 @@ def code_uses_state_contexts(javascript_code: str) -> bool:
4119
4118
 
4120
4119
  def reload_state_module(
4121
4120
  module: str,
4122
- state: Type[BaseState] = State,
4121
+ state: type[BaseState] = State,
4123
4122
  ) -> None:
4124
4123
  """Reset rx.State subclasses to avoid conflict when reloading.
4125
4124