reflex 0.7.1a3__py3-none-any.whl → 0.7.2a1__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 (226) hide show
  1. reflex/.templates/jinja/web/utils/context.js.jinja2 +8 -8
  2. reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +3 -3
  3. reflex/admin.py +1 -2
  4. reflex/app.py +53 -50
  5. reflex/app_mixins/lifespan.py +2 -2
  6. reflex/app_mixins/middleware.py +1 -2
  7. reflex/assets.py +1 -2
  8. reflex/base.py +2 -2
  9. reflex/compiler/compiler.py +51 -16
  10. reflex/compiler/utils.py +4 -13
  11. reflex/components/base/app_wrap.pyi +7 -7
  12. reflex/components/base/bare.py +3 -3
  13. reflex/components/base/body.pyi +7 -7
  14. reflex/components/base/document.py +1 -3
  15. reflex/components/base/document.pyi +32 -32
  16. reflex/components/base/error_boundary.py +2 -4
  17. reflex/components/base/error_boundary.pyi +11 -13
  18. reflex/components/base/fragment.pyi +7 -7
  19. reflex/components/base/head.pyi +13 -13
  20. reflex/components/base/link.pyi +22 -22
  21. reflex/components/base/meta.py +5 -7
  22. reflex/components/base/meta.pyi +40 -40
  23. reflex/components/base/script.pyi +11 -14
  24. reflex/components/base/strict_mode.pyi +7 -7
  25. reflex/components/component.py +188 -113
  26. reflex/components/core/auto_scroll.py +8 -1
  27. reflex/components/core/auto_scroll.pyi +183 -210
  28. reflex/components/core/banner.py +2 -4
  29. reflex/components/core/banner.pyi +390 -444
  30. reflex/components/core/breakpoints.py +5 -5
  31. reflex/components/core/client_side_routing.pyi +14 -14
  32. reflex/components/core/clipboard.py +4 -4
  33. reflex/components/core/clipboard.pyi +12 -14
  34. reflex/components/core/cond.py +17 -25
  35. reflex/components/core/debounce.py +3 -3
  36. reflex/components/core/debounce.pyi +14 -14
  37. reflex/components/core/foreach.py +7 -2
  38. reflex/components/core/html.py +1 -3
  39. reflex/components/core/html.pyi +184 -213
  40. reflex/components/core/match.py +15 -19
  41. reflex/components/core/sticky.pyi +930 -1078
  42. reflex/components/core/upload.py +4 -4
  43. reflex/components/core/upload.pyi +62 -62
  44. reflex/components/datadisplay/code.py +6 -6
  45. reflex/components/datadisplay/code.pyi +1159 -1165
  46. reflex/components/datadisplay/dataeditor.py +49 -49
  47. reflex/components/datadisplay/dataeditor.pyi +95 -123
  48. reflex/components/datadisplay/logo.py +1 -3
  49. reflex/components/datadisplay/shiki_code_block.py +8 -10
  50. reflex/components/datadisplay/shiki_code_block.pyi +1678 -1720
  51. reflex/components/el/element.pyi +7 -7
  52. reflex/components/el/elements/base.pyi +183 -210
  53. reflex/components/el/elements/forms.py +23 -23
  54. reflex/components/el/elements/forms.pyi +2571 -2933
  55. reflex/components/el/elements/inline.py +4 -4
  56. reflex/components/el/elements/inline.pyi +5191 -5953
  57. reflex/components/el/elements/media.py +47 -47
  58. reflex/components/el/elements/media.pyi +4802 -5500
  59. reflex/components/el/elements/metadata.py +1 -3
  60. reflex/components/el/elements/metadata.pyi +782 -896
  61. reflex/components/el/elements/other.pyi +1278 -1467
  62. reflex/components/el/elements/scripts.pyi +580 -667
  63. reflex/components/el/elements/sectioning.pyi +2761 -3166
  64. reflex/components/el/elements/tables.pyi +1840 -2119
  65. reflex/components/el/elements/typography.pyi +2772 -3179
  66. reflex/components/gridjs/datatable.py +7 -7
  67. reflex/components/gridjs/datatable.pyi +19 -19
  68. reflex/components/lucide/icon.pyi +21 -21
  69. reflex/components/markdown/markdown.py +2 -2
  70. reflex/components/markdown/markdown.pyi +9 -9
  71. reflex/components/moment/moment.py +11 -12
  72. reflex/components/moment/moment.pyi +44 -47
  73. reflex/components/next/base.pyi +7 -7
  74. reflex/components/next/image.py +3 -3
  75. reflex/components/next/image.pyi +19 -21
  76. reflex/components/next/link.pyi +9 -9
  77. reflex/components/next/video.py +1 -3
  78. reflex/components/next/video.pyi +9 -9
  79. reflex/components/plotly/plotly.py +22 -45
  80. reflex/components/plotly/plotly.pyi +164 -164
  81. reflex/components/radix/primitives/accordion.py +14 -14
  82. reflex/components/radix/primitives/accordion.pyi +439 -487
  83. reflex/components/radix/primitives/base.py +1 -3
  84. reflex/components/radix/primitives/base.pyi +15 -15
  85. reflex/components/radix/primitives/drawer.py +3 -3
  86. reflex/components/radix/primitives/drawer.pyi +110 -116
  87. reflex/components/radix/primitives/form.py +1 -1
  88. reflex/components/radix/primitives/form.pyi +668 -752
  89. reflex/components/radix/primitives/progress.py +6 -6
  90. reflex/components/radix/primitives/progress.pyi +225 -243
  91. reflex/components/radix/primitives/slider.py +6 -6
  92. reflex/components/radix/primitives/slider.pyi +52 -55
  93. reflex/components/radix/themes/base.py +3 -6
  94. reflex/components/radix/themes/base.pyi +197 -303
  95. reflex/components/radix/themes/color_mode.py +5 -5
  96. reflex/components/radix/themes/color_mode.pyi +366 -436
  97. reflex/components/radix/themes/components/alert_dialog.pyi +229 -262
  98. reflex/components/radix/themes/components/aspect_ratio.py +1 -3
  99. reflex/components/radix/themes/components/aspect_ratio.pyi +8 -8
  100. reflex/components/radix/themes/components/avatar.pyi +79 -94
  101. reflex/components/radix/themes/components/badge.pyi +252 -295
  102. reflex/components/radix/themes/components/button.pyi +269 -314
  103. reflex/components/radix/themes/components/callout.py +2 -2
  104. reflex/components/radix/themes/components/callout.pyi +1116 -1290
  105. reflex/components/radix/themes/components/card.pyi +194 -229
  106. reflex/components/radix/themes/components/checkbox.pyi +243 -278
  107. reflex/components/radix/themes/components/checkbox_cards.py +3 -7
  108. reflex/components/radix/themes/components/checkbox_cards.pyi +101 -135
  109. reflex/components/radix/themes/components/checkbox_group.py +2 -2
  110. reflex/components/radix/themes/components/checkbox_group.pyi +83 -96
  111. reflex/components/radix/themes/components/context_menu.py +18 -15
  112. reflex/components/radix/themes/components/context_menu.pyi +408 -458
  113. reflex/components/radix/themes/components/data_list.pyi +122 -147
  114. reflex/components/radix/themes/components/dialog.pyi +231 -264
  115. reflex/components/radix/themes/components/dropdown_menu.py +16 -13
  116. reflex/components/radix/themes/components/dropdown_menu.pyi +223 -246
  117. reflex/components/radix/themes/components/hover_card.py +2 -2
  118. reflex/components/radix/themes/components/hover_card.pyi +237 -282
  119. reflex/components/radix/themes/components/icon_button.pyi +269 -314
  120. reflex/components/radix/themes/components/inset.py +8 -8
  121. reflex/components/radix/themes/components/inset.pyi +232 -292
  122. reflex/components/radix/themes/components/popover.py +2 -2
  123. reflex/components/radix/themes/components/popover.pyi +229 -271
  124. reflex/components/radix/themes/components/progress.pyi +80 -96
  125. reflex/components/radix/themes/components/radio.pyi +73 -86
  126. reflex/components/radix/themes/components/radio_cards.py +4 -8
  127. reflex/components/radix/themes/components/radio_cards.pyi +117 -154
  128. reflex/components/radix/themes/components/radio_group.py +3 -3
  129. reflex/components/radix/themes/components/radio_group.pyi +250 -291
  130. reflex/components/radix/themes/components/scroll_area.pyi +14 -20
  131. reflex/components/radix/themes/components/segmented_control.py +6 -6
  132. reflex/components/radix/themes/components/segmented_control.pyi +89 -108
  133. reflex/components/radix/themes/components/select.py +7 -7
  134. reflex/components/radix/themes/components/select.pyi +376 -444
  135. reflex/components/radix/themes/components/separator.pyi +79 -93
  136. reflex/components/radix/themes/components/skeleton.pyi +32 -26
  137. reflex/components/radix/themes/components/slider.py +8 -8
  138. reflex/components/radix/themes/components/slider.pyi +99 -122
  139. reflex/components/radix/themes/components/spinner.pyi +12 -19
  140. reflex/components/radix/themes/components/switch.pyi +84 -99
  141. reflex/components/radix/themes/components/table.py +9 -9
  142. reflex/components/radix/themes/components/table.pyi +1440 -1794
  143. reflex/components/radix/themes/components/tabs.py +4 -4
  144. reflex/components/radix/themes/components/tabs.pyi +120 -132
  145. reflex/components/radix/themes/components/text_area.pyi +281 -331
  146. reflex/components/radix/themes/components/text_field.py +2 -2
  147. reflex/components/radix/themes/components/text_field.pyi +639 -734
  148. reflex/components/radix/themes/components/tooltip.py +6 -6
  149. reflex/components/radix/themes/components/tooltip.pyi +34 -43
  150. reflex/components/radix/themes/layout/base.pyi +85 -182
  151. reflex/components/radix/themes/layout/box.pyi +183 -210
  152. reflex/components/radix/themes/layout/center.pyi +225 -286
  153. reflex/components/radix/themes/layout/container.pyi +191 -224
  154. reflex/components/radix/themes/layout/flex.py +2 -2
  155. reflex/components/radix/themes/layout/flex.pyi +225 -286
  156. reflex/components/radix/themes/layout/grid.py +2 -2
  157. reflex/components/radix/themes/layout/grid.pyi +245 -315
  158. reflex/components/radix/themes/layout/list.py +2 -2
  159. reflex/components/radix/themes/layout/list.pyi +712 -815
  160. reflex/components/radix/themes/layout/section.pyi +187 -221
  161. reflex/components/radix/themes/layout/spacer.pyi +225 -286
  162. reflex/components/radix/themes/layout/stack.pyi +625 -768
  163. reflex/components/radix/themes/typography/blockquote.pyi +257 -299
  164. reflex/components/radix/themes/typography/code.pyi +259 -304
  165. reflex/components/radix/themes/typography/heading.pyi +272 -324
  166. reflex/components/radix/themes/typography/link.pyi +302 -358
  167. reflex/components/radix/themes/typography/text.pyi +1669 -1945
  168. reflex/components/react_player/audio.pyi +20 -22
  169. reflex/components/react_player/react_player.pyi +19 -19
  170. reflex/components/react_player/video.pyi +20 -22
  171. reflex/components/recharts/cartesian.py +100 -97
  172. reflex/components/recharts/cartesian.pyi +891 -1007
  173. reflex/components/recharts/charts.py +42 -42
  174. reflex/components/recharts/charts.pyi +212 -249
  175. reflex/components/recharts/general.py +22 -21
  176. reflex/components/recharts/general.pyi +198 -223
  177. reflex/components/recharts/polar.py +42 -45
  178. reflex/components/recharts/polar.pyi +254 -288
  179. reflex/components/recharts/recharts.pyi +13 -13
  180. reflex/components/sonner/toast.py +20 -20
  181. reflex/components/sonner/toast.pyi +58 -61
  182. reflex/components/suneditor/editor.py +9 -9
  183. reflex/components/suneditor/editor.pyi +78 -83
  184. reflex/components/tags/cond_tag.py +2 -2
  185. reflex/components/tags/iter_tag.py +10 -14
  186. reflex/components/tags/match_tag.py +2 -2
  187. reflex/components/tags/tag.py +10 -10
  188. reflex/config.py +36 -35
  189. reflex/constants/__init__.py +56 -53
  190. reflex/custom_components/custom_components.py +6 -7
  191. reflex/event.py +38 -42
  192. reflex/experimental/client_state.py +2 -4
  193. reflex/experimental/layout.py +2 -2
  194. reflex/experimental/layout.pyi +579 -663
  195. reflex/istate/data.py +4 -5
  196. reflex/middleware/hydrate_middleware.py +2 -2
  197. reflex/middleware/middleware.py +2 -2
  198. reflex/model.py +3 -5
  199. reflex/page.py +2 -2
  200. reflex/reflex.py +9 -10
  201. reflex/state.py +77 -49
  202. reflex/style.py +9 -3
  203. reflex/testing.py +21 -24
  204. reflex/utils/console.py +1 -1
  205. reflex/utils/decorator.py +26 -1
  206. reflex/utils/exec.py +6 -11
  207. reflex/utils/export.py +2 -3
  208. reflex/utils/format.py +4 -4
  209. reflex/utils/imports.py +12 -12
  210. reflex/utils/prerequisites.py +35 -84
  211. reflex/utils/processes.py +5 -5
  212. reflex/utils/pyi_generator.py +33 -22
  213. reflex/utils/serializers.py +60 -15
  214. reflex/utils/types.py +237 -56
  215. reflex/vars/base.py +122 -72
  216. reflex/vars/datetime.py +2 -2
  217. reflex/vars/function.py +52 -55
  218. reflex/vars/number.py +59 -5
  219. reflex/vars/object.py +57 -26
  220. reflex/vars/sequence.py +983 -958
  221. {reflex-0.7.1a3.dist-info → reflex-0.7.2a1.dist-info}/METADATA +3 -6
  222. reflex-0.7.2a1.dist-info/RECORD +405 -0
  223. {reflex-0.7.1a3.dist-info → reflex-0.7.2a1.dist-info}/WHEEL +1 -1
  224. reflex-0.7.1a3.dist-info/RECORD +0 -405
  225. {reflex-0.7.1a3.dist-info → reflex-0.7.2a1.dist-info}/LICENSE +0 -0
  226. {reflex-0.7.1a3.dist-info → reflex-0.7.2a1.dist-info}/entry_points.txt +0 -0
@@ -3,10 +3,10 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import dataclasses
6
- from typing import Any, Dict, List, Mapping, Optional, Sequence
6
+ from typing import Any, List, Mapping, Sequence
7
7
 
8
8
  from reflex.event import EventChain
9
- from reflex.utils import format, types
9
+ from reflex.utils import format
10
10
  from reflex.vars.base import LiteralVar, Var
11
11
 
12
12
 
@@ -38,16 +38,16 @@ class Tag:
38
38
  name: str = ""
39
39
 
40
40
  # The props of the tag.
41
- props: Dict[str, Any] = dataclasses.field(default_factory=dict)
41
+ props: dict[str, Any] = dataclasses.field(default_factory=dict)
42
42
 
43
43
  # The inner contents of the tag.
44
44
  contents: str = ""
45
45
 
46
46
  # Special props that aren't key value pairs.
47
- special_props: List[Var] = dataclasses.field(default_factory=list)
47
+ special_props: list[Var] = dataclasses.field(default_factory=list)
48
48
 
49
49
  # The children components.
50
- children: List[Any] = dataclasses.field(default_factory=list)
50
+ children: list[Any] = dataclasses.field(default_factory=list)
51
51
 
52
52
  def __post_init__(self):
53
53
  """Post initialize the tag."""
@@ -83,14 +83,14 @@ class Tag:
83
83
  """Iterate over the tag's fields.
84
84
 
85
85
  Yields:
86
- Tuple[str, Any]: The field name and value.
86
+ tuple[str, Any]: The field name and value.
87
87
  """
88
88
  for field in dataclasses.fields(self):
89
89
  rendered_value = render_prop(getattr(self, field.name))
90
90
  if rendered_value is not None:
91
91
  yield field.name, rendered_value
92
92
 
93
- def add_props(self, **kwargs: Optional[Any]) -> Tag:
93
+ def add_props(self, **kwargs: Any | None) -> Tag:
94
94
  """Add props to the tag.
95
95
 
96
96
  Args:
@@ -103,9 +103,9 @@ class Tag:
103
103
  {
104
104
  format.to_camel_case(name, treat_hyphens_as_underscores=False): (
105
105
  prop
106
- if types._isinstance(prop, (EventChain, Mapping))
106
+ if isinstance(prop, (EventChain, Mapping))
107
107
  else LiteralVar.create(prop)
108
- ) # rx.color is always a string
108
+ )
109
109
  for name, prop in kwargs.items()
110
110
  if self.is_valid_prop(prop)
111
111
  }
@@ -128,7 +128,7 @@ class Tag:
128
128
  return self
129
129
 
130
130
  @staticmethod
131
- def is_valid_prop(prop: Optional[Var]) -> bool:
131
+ def is_valid_prop(prop: Var | None) -> bool:
132
132
  """Check if the prop is valid.
133
133
 
134
134
  Args:
reflex/config.py CHANGED
@@ -22,11 +22,7 @@ from typing import (
22
22
  Annotated,
23
23
  Any,
24
24
  Callable,
25
- Dict,
26
25
  Generic,
27
- List,
28
- Optional,
29
- Set,
30
26
  TypeVar,
31
27
  get_args,
32
28
  get_origin,
@@ -40,7 +36,12 @@ from reflex import constants
40
36
  from reflex.base import Base
41
37
  from reflex.utils import console
42
38
  from reflex.utils.exceptions import ConfigError, EnvironmentVarValueError
43
- from reflex.utils.types import GenericType, is_union, value_inside_optional
39
+ from reflex.utils.types import (
40
+ GenericType,
41
+ is_union,
42
+ true_type_for_pydantic_field,
43
+ value_inside_optional,
44
+ )
44
45
 
45
46
  try:
46
47
  from dotenv import load_dotenv # pyright: ignore [reportMissingImports]
@@ -52,10 +53,10 @@ class DBConfig(Base):
52
53
  """Database config."""
53
54
 
54
55
  engine: str
55
- username: Optional[str] = ""
56
- password: Optional[str] = ""
57
- host: Optional[str] = ""
58
- port: Optional[int] = None
56
+ username: str | None = ""
57
+ password: str | None = ""
58
+ host: str | None = ""
59
+ port: int | None = None
59
60
  database: str
60
61
 
61
62
  @classmethod
@@ -361,7 +362,7 @@ class EnvVar(Generic[T]):
361
362
  """
362
363
  return interpret_env_var_value(value, self.type_, self.name)
363
364
 
364
- def getenv(self) -> Optional[T]:
365
+ def getenv(self) -> T | None:
365
366
  """Get the interpreted environment variable value.
366
367
 
367
368
  Returns:
@@ -598,16 +599,16 @@ class EnvironmentVariables:
598
599
  REFLEX_USE_NPM: EnvVar[bool] = env_var(False)
599
600
 
600
601
  # The npm registry to use.
601
- NPM_CONFIG_REGISTRY: EnvVar[Optional[str]] = env_var(None)
602
+ NPM_CONFIG_REGISTRY: EnvVar[str | None] = env_var(None)
602
603
 
603
604
  # Whether to use Granian for the backend. Otherwise, use Uvicorn.
604
605
  REFLEX_USE_GRANIAN: EnvVar[bool] = env_var(False)
605
606
 
606
607
  # The username to use for authentication on python package repository. Username and password must both be provided.
607
- TWINE_USERNAME: EnvVar[Optional[str]] = env_var(None)
608
+ TWINE_USERNAME: EnvVar[str | None] = env_var(None)
608
609
 
609
610
  # The password to use for authentication on python package repository. Username and password must both be provided.
610
- TWINE_PASSWORD: EnvVar[Optional[str]] = env_var(None)
611
+ TWINE_PASSWORD: EnvVar[str | None] = env_var(None)
611
612
 
612
613
  # Whether to use the system installed bun. If set to false, bun will be bundled with the app.
613
614
  REFLEX_USE_SYSTEM_BUN: EnvVar[bool] = env_var(False)
@@ -632,13 +633,13 @@ class EnvironmentVariables:
632
633
  Path(constants.Dirs.UPLOADED_FILES)
633
634
  )
634
635
 
635
- REFLEX_COMPILE_EXECUTOR: EnvVar[Optional[ExecutorType]] = env_var(None)
636
+ REFLEX_COMPILE_EXECUTOR: EnvVar[ExecutorType | None] = env_var(None)
636
637
 
637
638
  # Whether to use separate processes to compile the frontend and how many. If not set, defaults to thread executor.
638
- REFLEX_COMPILE_PROCESSES: EnvVar[Optional[int]] = env_var(None)
639
+ REFLEX_COMPILE_PROCESSES: EnvVar[int | None] = env_var(None)
639
640
 
640
641
  # Whether to use separate threads to compile the frontend and how many. Defaults to `min(32, os.cpu_count() + 4)`.
641
- REFLEX_COMPILE_THREADS: EnvVar[Optional[int]] = env_var(None)
642
+ REFLEX_COMPILE_THREADS: EnvVar[int | None] = env_var(None)
642
643
 
643
644
  # The directory to store reflex dependencies.
644
645
  REFLEX_DIR: EnvVar[Path] = env_var(constants.Reflex.DIR)
@@ -708,10 +709,10 @@ class EnvironmentVariables:
708
709
  REFLEX_USE_TURBOPACK: EnvVar[bool] = env_var(True)
709
710
 
710
711
  # Additional paths to include in the hot reload. Separated by a colon.
711
- REFLEX_HOT_RELOAD_INCLUDE_PATHS: EnvVar[List[Path]] = env_var([])
712
+ REFLEX_HOT_RELOAD_INCLUDE_PATHS: EnvVar[list[Path]] = env_var([])
712
713
 
713
714
  # Paths to exclude from the hot reload. Takes precedence over include paths. Separated by a colon.
714
- REFLEX_HOT_RELOAD_EXCLUDE_PATHS: EnvVar[List[Path]] = env_var([])
715
+ REFLEX_HOT_RELOAD_EXCLUDE_PATHS: EnvVar[list[Path]] = env_var([])
715
716
 
716
717
  # Enables different behavior for when the backend would do a cold start if it was inactive.
717
718
  REFLEX_DOES_BACKEND_COLD_START: EnvVar[bool] = env_var(False)
@@ -761,7 +762,7 @@ class Config(Base):
761
762
  app_name: str
762
763
 
763
764
  # The path to the app module.
764
- app_module_import: Optional[str] = None
765
+ app_module_import: str | None = None
765
766
 
766
767
  # The log level to use.
767
768
  loglevel: constants.LogLevel = constants.LogLevel.DEFAULT
@@ -779,21 +780,19 @@ class Config(Base):
779
780
  api_url: str = f"http://localhost:{constants.DefaultPorts.BACKEND_PORT}"
780
781
 
781
782
  # The url the frontend will be hosted on.
782
- deploy_url: Optional[str] = (
783
- f"http://localhost:{constants.DefaultPorts.FRONTEND_PORT}"
784
- )
783
+ deploy_url: str | None = f"http://localhost:{constants.DefaultPorts.FRONTEND_PORT}"
785
784
 
786
785
  # The url the backend will be hosted on.
787
786
  backend_host: str = "0.0.0.0"
788
787
 
789
788
  # The database url used by rx.Model.
790
- db_url: Optional[str] = "sqlite:///reflex.db"
789
+ db_url: str | None = "sqlite:///reflex.db"
791
790
 
792
791
  # The async database url used by rx.Model.
793
- async_db_url: Optional[str] = None
792
+ async_db_url: str | None = None
794
793
 
795
794
  # The redis url
796
- redis_url: Optional[str] = None
795
+ redis_url: str | None = None
797
796
 
798
797
  # Telemetry opt-in.
799
798
  telemetry_enabled: bool = True
@@ -805,10 +804,10 @@ class Config(Base):
805
804
  static_page_generation_timeout: int = 60
806
805
 
807
806
  # List of origins that are allowed to connect to the backend API.
808
- cors_allowed_origins: List[str] = ["*"]
807
+ cors_allowed_origins: list[str] = ["*"]
809
808
 
810
809
  # Tailwind config.
811
- tailwind: Optional[Dict[str, Any]] = {"plugins": ["@tailwindcss/typography"]}
810
+ tailwind: dict[str, Any] | None = {"plugins": ["@tailwindcss/typography"]}
812
811
 
813
812
  # Timeout when launching the gunicorn server. TODO(rename this to backend_timeout?)
814
813
  timeout: int = 120
@@ -820,7 +819,7 @@ class Config(Base):
820
819
  react_strict_mode: bool = True
821
820
 
822
821
  # Additional frontend packages to install.
823
- frontend_packages: List[str] = []
822
+ frontend_packages: list[str] = []
824
823
 
825
824
  # The hosting service backend URL.
826
825
  cp_backend_url: str = Hosting.HOSTING_SERVICE
@@ -831,7 +830,7 @@ class Config(Base):
831
830
  gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"
832
831
 
833
832
  # Number of gunicorn workers from user
834
- gunicorn_workers: Optional[int] = None
833
+ gunicorn_workers: int | None = None
835
834
 
836
835
  # Number of requests before a worker is restarted; set to 0 to disable
837
836
  gunicorn_max_requests: int = 100
@@ -852,19 +851,19 @@ class Config(Base):
852
851
  redis_token_expiration: int = constants.Expiration.TOKEN
853
852
 
854
853
  # Attributes that were explicitly set by the user.
855
- _non_default_attributes: Set[str] = pydantic.PrivateAttr(set())
854
+ _non_default_attributes: set[str] = pydantic.PrivateAttr(set())
856
855
 
857
856
  # Path to file containing key-values pairs to override in the environment; Dotenv format.
858
- env_file: Optional[str] = None
857
+ env_file: str | None = None
859
858
 
860
859
  # Whether to display the sticky "Built with Reflex" badge on all pages.
861
- show_built_with_reflex: Optional[bool] = None
860
+ show_built_with_reflex: bool | None = None
862
861
 
863
862
  # Whether the app is running in the reflex cloud environment.
864
863
  is_reflex_cloud: bool = False
865
864
 
866
- # Extra overlay function to run after the app is built. Formatted such that `from path_0.path_1... import path[-1]`, and calling it with no arguments would work. For example, "reflex.components.moment.momnet".
867
- extra_overlay_function: Optional[str] = None
865
+ # Extra overlay function to run after the app is built. Formatted such that `from path_0.path_1... import path[-1]`, and calling it with no arguments would work. For example, "reflex.components.moment.moment".
866
+ extra_overlay_function: str | None = None
868
867
 
869
868
  def __init__(self, *args, **kwargs):
870
869
  """Initialize the config values.
@@ -949,7 +948,9 @@ class Config(Base):
949
948
  # If the env var is set, override the config value.
950
949
  if env_var is not None:
951
950
  # Interpret the value.
952
- value = interpret_env_var_value(env_var, field.outer_type_, field.name)
951
+ value = interpret_env_var_value(
952
+ env_var, true_type_for_pydantic_field(field), field.name
953
+ )
953
954
 
954
955
  # Set the value.
955
956
  updated_values[key] = value
@@ -60,57 +60,60 @@ from .route import (
60
60
  from .state import StateManagerMode
61
61
  from .style import Tailwind
62
62
 
63
- __ALL__ = [
64
- ALEMBIC_CONFIG,
65
- Bun,
66
- ColorMode,
67
- Config,
68
- COOKIES,
69
- CompileContext,
70
- ComponentName,
71
- CustomComponents,
72
- DefaultPage,
73
- DefaultPorts,
74
- Dirs,
75
- Endpoint,
76
- Env,
77
- EventTriggers,
78
- Expiration,
79
- Ext,
80
- Fnm,
81
- REFLEX_VAR_CLOSING_TAG,
82
- REFLEX_VAR_OPENING_TAG,
83
- GitIgnore,
84
- Hooks,
85
- Imports,
86
- IS_WINDOWS,
87
- LOCAL_STORAGE,
88
- SESSION_STORAGE,
89
- LogLevel,
90
- MemoizationDisposition,
91
- MemoizationMode,
92
- Next,
93
- Node,
94
- NOCOMPILE_FILE,
95
- PackageJson,
96
- PageNames,
97
- Page404,
98
- Ping,
99
- POLLING_MAX_HTTP_BUFFER_SIZE,
100
- PYTEST_CURRENT_TEST,
101
- Reflex,
102
- RequirementsTxt,
103
- RouteArgType,
104
- RouteRegex,
105
- RouteVar,
106
- ROUTER,
107
- ROUTER_DATA,
108
- ROUTER_DATA_INCLUDE,
109
- ROUTE_NOT_FOUND,
110
- SETTER_PREFIX,
111
- SocketEvent,
112
- StateManagerMode,
113
- Tailwind,
114
- Templates,
115
- CompileVars,
63
+ __all__ = [
64
+ "ALEMBIC_CONFIG",
65
+ "APP_HARNESS_FLAG",
66
+ "COOKIES",
67
+ "IS_LINUX",
68
+ "IS_MACOS",
69
+ "IS_WINDOWS",
70
+ "LOCAL_STORAGE",
71
+ "NOCOMPILE_FILE",
72
+ "POLLING_MAX_HTTP_BUFFER_SIZE",
73
+ "PYTEST_CURRENT_TEST",
74
+ "REFLEX_VAR_CLOSING_TAG",
75
+ "REFLEX_VAR_OPENING_TAG",
76
+ "ROUTER",
77
+ "ROUTER_DATA",
78
+ "ROUTER_DATA_INCLUDE",
79
+ "ROUTE_NOT_FOUND",
80
+ "SESSION_STORAGE",
81
+ "SETTER_PREFIX",
82
+ "Bun",
83
+ "ColorMode",
84
+ "CompileContext",
85
+ "CompileVars",
86
+ "ComponentName",
87
+ "Config",
88
+ "CustomComponents",
89
+ "DefaultPage",
90
+ "DefaultPorts",
91
+ "Dirs",
92
+ "Endpoint",
93
+ "Env",
94
+ "EventTriggers",
95
+ "Expiration",
96
+ "Ext",
97
+ "Fnm",
98
+ "GitIgnore",
99
+ "Hooks",
100
+ "Imports",
101
+ "LogLevel",
102
+ "MemoizationDisposition",
103
+ "MemoizationMode",
104
+ "Next",
105
+ "Node",
106
+ "PackageJson",
107
+ "Page404",
108
+ "PageNames",
109
+ "Ping",
110
+ "Reflex",
111
+ "RequirementsTxt",
112
+ "RouteArgType",
113
+ "RouteRegex",
114
+ "RouteVar",
115
+ "SocketEvent",
116
+ "StateManagerMode",
117
+ "Tailwind",
118
+ "Templates",
116
119
  ]
@@ -9,7 +9,6 @@ import sys
9
9
  from collections import namedtuple
10
10
  from contextlib import contextmanager
11
11
  from pathlib import Path
12
- from typing import Optional, Tuple
13
12
 
14
13
  import httpx
15
14
  import tomlkit
@@ -311,7 +310,7 @@ def _populate_custom_component_project(name_variants: NameVariants):
311
310
 
312
311
  @custom_components_cli.command(name="init")
313
312
  def init(
314
- library_name: Optional[str] = typer.Option(
313
+ library_name: str | None = typer.Option(
315
314
  None,
316
315
  help="The name of your library. On PyPI, package will be published as `reflex-{library-name}`.",
317
316
  ),
@@ -604,26 +603,26 @@ def _ensure_dist_dir(version_to_publish: str, build: bool):
604
603
 
605
604
  @custom_components_cli.command(name="publish")
606
605
  def publish(
607
- repository: Optional[str] = typer.Option(
606
+ repository: str | None = typer.Option(
608
607
  None,
609
608
  "-r",
610
609
  "--repository",
611
610
  help="The name of the repository. Defaults to pypi. Only supports pypi and testpypi (Test PyPI) for now.",
612
611
  ),
613
- token: Optional[str] = typer.Option(
612
+ token: str | None = typer.Option(
614
613
  None,
615
614
  "-t",
616
615
  "--token",
617
616
  help="The API token to use for authentication on python package repository. If token is provided, no username/password should be provided at the same time",
618
617
  ),
619
- username: Optional[str] = typer.Option(
618
+ username: str | None = typer.Option(
620
619
  environment.TWINE_USERNAME.get(),
621
620
  "-u",
622
621
  "--username",
623
622
  show_default="TWINE_USERNAME environment variable value if set",
624
623
  help="The username to use for authentication on python package repository. Username and password must both be provided.",
625
624
  ),
626
- password: Optional[str] = typer.Option(
625
+ password: str | None = typer.Option(
627
626
  environment.TWINE_PASSWORD.get(),
628
627
  "-p",
629
628
  "--password",
@@ -927,7 +926,7 @@ def _validate_url_with_protocol_prefix(url: str | None) -> bool:
927
926
  return not url or (url.startswith("http://") or url.startswith("https://"))
928
927
 
929
928
 
930
- def _get_file_from_prompt_in_loop() -> Tuple[bytes, str] | None:
929
+ def _get_file_from_prompt_in_loop() -> tuple[bytes, str] | None:
931
930
  image_file = file_extension = None
932
931
  while image_file is None:
933
932
  image_filepath = Path(