reflex 0.6.4a1__py3-none-any.whl → 0.6.4a3__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.

@@ -645,7 +645,7 @@ class Component(BaseComponent, ABC):
645
645
  # Look for component specific triggers,
646
646
  # e.g. variable declared as EventHandler types.
647
647
  for field in self.get_fields().values():
648
- if types._issubclass(field.type_, EventHandler):
648
+ if types._issubclass(field.outer_type_, EventHandler):
649
649
  args_spec = None
650
650
  annotation = field.annotation
651
651
  if (metadata := getattr(annotation, "__metadata__", None)) is not None:
reflex/config.py CHANGED
@@ -3,14 +3,16 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import dataclasses
6
+ import enum
6
7
  import importlib
8
+ import inspect
7
9
  import os
8
10
  import sys
9
11
  import urllib.parse
10
12
  from pathlib import Path
11
13
  from typing import Any, Dict, List, Optional, Set
12
14
 
13
- from typing_extensions import get_type_hints
15
+ from typing_extensions import Annotated, get_type_hints
14
16
 
15
17
  from reflex.utils.exceptions import ConfigError, EnvironmentVarValueError
16
18
  from reflex.utils.types import GenericType, is_union, value_inside_optional
@@ -202,8 +204,8 @@ def interpret_int_env(value: str, field_name: str) -> int:
202
204
  ) from ve
203
205
 
204
206
 
205
- def interpret_path_env(value: str, field_name: str) -> Path:
206
- """Interpret a path environment variable value.
207
+ def interpret_existing_path_env(value: str, field_name: str) -> ExistingPath:
208
+ """Interpret a path environment variable value as an existing path.
207
209
 
208
210
  Args:
209
211
  value: The environment variable value.
@@ -221,6 +223,41 @@ def interpret_path_env(value: str, field_name: str) -> Path:
221
223
  return path
222
224
 
223
225
 
226
+ def interpret_path_env(value: str, field_name: str) -> Path:
227
+ """Interpret a path environment variable value.
228
+
229
+ Args:
230
+ value: The environment variable value.
231
+ field_name: The field name.
232
+
233
+ Returns:
234
+ The interpreted value.
235
+ """
236
+ return Path(value)
237
+
238
+
239
+ def interpret_enum_env(value: str, field_type: GenericType, field_name: str) -> Any:
240
+ """Interpret an enum environment variable value.
241
+
242
+ Args:
243
+ value: The environment variable value.
244
+ field_type: The field type.
245
+ field_name: The field name.
246
+
247
+ Returns:
248
+ The interpreted value.
249
+
250
+ Raises:
251
+ EnvironmentVarValueError: If the value is invalid.
252
+ """
253
+ try:
254
+ return field_type(value)
255
+ except ValueError as ve:
256
+ raise EnvironmentVarValueError(
257
+ f"Invalid enum value: {value} for {field_name}"
258
+ ) from ve
259
+
260
+
224
261
  def interpret_env_var_value(
225
262
  value: str, field_type: GenericType, field_name: str
226
263
  ) -> Any:
@@ -252,6 +289,10 @@ def interpret_env_var_value(
252
289
  return interpret_int_env(value, field_name)
253
290
  elif field_type is Path:
254
291
  return interpret_path_env(value, field_name)
292
+ elif field_type is ExistingPath:
293
+ return interpret_existing_path_env(value, field_name)
294
+ elif inspect.isclass(field_type) and issubclass(field_type, enum.Enum):
295
+ return interpret_enum_env(value, field_type, field_name)
255
296
 
256
297
  else:
257
298
  raise ValueError(
@@ -259,6 +300,13 @@ def interpret_env_var_value(
259
300
  )
260
301
 
261
302
 
303
+ class PathExistsFlag:
304
+ """Flag to indicate that a path must exist."""
305
+
306
+
307
+ ExistingPath = Annotated[Path, PathExistsFlag]
308
+
309
+
262
310
  @dataclasses.dataclass(init=False)
263
311
  class EnvironmentVariables:
264
312
  """Environment variables class to instantiate environment variables."""
@@ -288,7 +336,7 @@ class EnvironmentVariables:
288
336
  REFLEX_WEB_WORKDIR: Path = Path(constants.Dirs.WEB)
289
337
 
290
338
  # Path to the alembic config file
291
- ALEMBIC_CONFIG: Path = Path(constants.ALEMBIC_CONFIG)
339
+ ALEMBIC_CONFIG: ExistingPath = Path(constants.ALEMBIC_CONFIG)
292
340
 
293
341
  # Disable SSL verification for HTTPX requests.
294
342
  SSL_NO_VERIFY: bool = False
@@ -401,7 +449,7 @@ class Config(Base):
401
449
  telemetry_enabled: bool = True
402
450
 
403
451
  # The bun path
404
- bun_path: Path = constants.Bun.DEFAULT_PATH
452
+ bun_path: ExistingPath = constants.Bun.DEFAULT_PATH
405
453
 
406
454
  # List of origins that are allowed to connect to the backend API.
407
455
  cors_allowed_origins: List[str] = ["*"]
@@ -525,7 +573,7 @@ class Config(Base):
525
573
  )
526
574
 
527
575
  # Interpret the value.
528
- value = interpret_env_var_value(env_var, field.type_, field.name)
576
+ value = interpret_env_var_value(env_var, field.outer_type_, field.name)
529
577
 
530
578
  # Set the value.
531
579
  updated_values[key] = value
reflex/event.py CHANGED
@@ -1489,6 +1489,11 @@ if sys.version_info >= (3, 10):
1489
1489
  """
1490
1490
  return self
1491
1491
 
1492
+ @overload
1493
+ def __call__(
1494
+ self: EventCallback[Q, T],
1495
+ ) -> EventCallback[Q, T]: ...
1496
+
1492
1497
  @overload
1493
1498
  def __call__(
1494
1499
  self: EventCallback[Concatenate[V, Q], T], value: V | Var[V]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflex
3
- Version: 0.6.4a1
3
+ Version: 0.6.4a3
4
4
  Summary: Web apps in pure Python.
5
5
  Home-page: https://reflex.dev
6
6
  License: Apache-2.0
@@ -73,7 +73,7 @@ reflex/components/base/meta.py,sha256=GvcBACA4Q3ptW_EXdJ6Wpolhh0x6yMW7QsCasG3keb
73
73
  reflex/components/base/meta.pyi,sha256=k1zDuRCANHHb-4u6mf2oeN10tnPy3wXdpachYuJmh98,8844
74
74
  reflex/components/base/script.py,sha256=79Ae72us8sKFQfgPuSilWvJ7ePuQ6JnbLy_cfRSL5qk,2405
75
75
  reflex/components/base/script.pyi,sha256=WUGapktdmSODItM2OfnQOox1uW6ShdZWxegs1CUFG-o,3436
76
- reflex/components/component.py,sha256=QehzKgA1SAw8FGZZCtMGCIjZaO_lls3TKJbmnW8v5uw,79926
76
+ reflex/components/component.py,sha256=HVE9xGMK41jLqdf33X0EqgMEL2vexbnVb7BXH0qqNss,79932
77
77
  reflex/components/core/__init__.py,sha256=msAsWb_6bmZGSei4gEpyYczuJ0VNEZtg20fRtyb3wwM,1285
78
78
  reflex/components/core/__init__.pyi,sha256=hmng2kT4e3iBSSI_x9t7g2-58G6Cb4rhuwz_APJ-UZM,1994
79
79
  reflex/components/core/banner.py,sha256=1toGgoA-az12NMoJAJPMZ3hG5dcloGUJWTtGJYJtZAo,8753
@@ -321,7 +321,7 @@ reflex/components/tags/iter_tag.py,sha256=jS-Y08cmzzb8v3cp52q5PaVmwirpg4n3Br9JWA
321
321
  reflex/components/tags/match_tag.py,sha256=mqQF6fHhOSGSMdiaJ7YlwXSMhRtDmmIBu1Gw-VQQ324,586
322
322
  reflex/components/tags/tag.py,sha256=_4uQZ8ACy-SSaT27F60G8MffZZ8hNpVOkPy1RnVjlFY,3166
323
323
  reflex/components/tags/tagless.py,sha256=qO7Gm4V0ITDyymHkyltfz53155ZBt-W_WIPDYy93ca0,587
324
- reflex/config.py,sha256=rMwg44am7-xwZh0F4R3upO4Mxefq2PPju7AWMwatTGI,19386
324
+ reflex/config.py,sha256=0o1mKRwU4Jgnn1bLEqQe-VkjdsUN7GZJDyPZ5zhWJ5M,20716
325
325
  reflex/constants/__init__.py,sha256=EhuyigQOXLv1VEKktcEvBHna8XBmLYqR-4NwGhR7yno,2149
326
326
  reflex/constants/base.py,sha256=VjYwT1-BufAgRA5FahHww1CSE3Qe3fPGYsc1big3taE,7334
327
327
  reflex/constants/colors.py,sha256=gab_GwjKcbpRJGS2zX0gkmc_yFT1nmQbFDHqx0mXKB0,1625
@@ -336,7 +336,7 @@ reflex/constants/style.py,sha256=wu96TXQM-ILWMtXdGoHsztIK_GEzi70bjzutfLJf0WQ,475
336
336
  reflex/constants/utils.py,sha256=HGOSq9c-xGbCb1xoLAGLBdc-FOE8iuBzvuU24zSfsV0,789
337
337
  reflex/custom_components/__init__.py,sha256=R4zsvOi4dfPmHc18KEphohXnQFBPnUCb50cMR5hSLDE,36
338
338
  reflex/custom_components/custom_components.py,sha256=-N5yLKOs3Qd_Xho8Od8gDrniHw09KpJaU6Ir6bFg7_g,33011
339
- reflex/event.py,sha256=Fi25zwvSdpWZiZxiVXuT317SK7T7DQIbEAtq7lsMe5k,47475
339
+ reflex/event.py,sha256=f8Si07TMd_-b8Z6g9aM1rmBWm42pAGDo2yocFo1Ss0g,47593
340
340
  reflex/experimental/__init__.py,sha256=Tzh48jIncw2YzRFHh2SXWZ599TsHeY6_RrrWdK6gE2A,2085
341
341
  reflex/experimental/assets.py,sha256=GZRdfIs03HXCSShyvdztu6vFsJ9Z8W4ZFCjJGZrNURY,1837
342
342
  reflex/experimental/client_state.py,sha256=lrIAkE7JGFRlB3vDzVaGK40AGavATPJpjIKgYmugkr4,7904
@@ -384,8 +384,8 @@ reflex/vars/function.py,sha256=z21_USAycM-FtDRTCAw9i0is6es4EEr1Z1OK-vu9ke8,5254
384
384
  reflex/vars/number.py,sha256=jZO2Ol3VPKo1eM0eeHqGbDFZYdM0Oza_e_etnYKsM-Q,27452
385
385
  reflex/vars/object.py,sha256=hiEwf9CAE1EhCoQpuRYvGtG15ZxerALDSeIwte4YEVA,14339
386
386
  reflex/vars/sequence.py,sha256=9aCxJkPnf0qkaoj1cycKkzUsFv6kb-KKRYJe7L7gPc4,49972
387
- reflex-0.6.4a1.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
388
- reflex-0.6.4a1.dist-info/METADATA,sha256=3uQWzi1ZmGytMiP3GbqnPSpWXRbiKnlpDz0GQQB7WPk,12057
389
- reflex-0.6.4a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
390
- reflex-0.6.4a1.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
391
- reflex-0.6.4a1.dist-info/RECORD,,
387
+ reflex-0.6.4a3.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
388
+ reflex-0.6.4a3.dist-info/METADATA,sha256=dJV_AMzplftVol1ADFA9VtnC3UmCDSQfVnt2wPUmL0Q,12057
389
+ reflex-0.6.4a3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
390
+ reflex-0.6.4a3.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
391
+ reflex-0.6.4a3.dist-info/RECORD,,