reflex 0.6.4a2__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.

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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflex
3
- Version: 0.6.4a2
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
@@ -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
@@ -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.4a2.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
388
- reflex-0.6.4a2.dist-info/METADATA,sha256=uAu0PifoNTRjtYzLA6rqL49LHY5OD7sp_UM35cRgvtM,12057
389
- reflex-0.6.4a2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
390
- reflex-0.6.4a2.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
391
- reflex-0.6.4a2.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,,