reflex 0.4.7__py3-none-any.whl → 0.4.7a2__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.

@@ -71,28 +71,6 @@ def _create_package_config(module_name: str, package_name: str):
71
71
  )
72
72
 
73
73
 
74
- def _get_package_config(exit_on_fail: bool = True) -> dict:
75
- """Get the package configuration from the pyproject.toml file.
76
-
77
- Args:
78
- exit_on_fail: Whether to exit if the pyproject.toml file is not found.
79
-
80
- Returns:
81
- The package configuration.
82
-
83
- Raises:
84
- Exit: If the pyproject.toml file is not found.
85
- """
86
- try:
87
- with open(CustomComponents.PYPROJECT_TOML, "rb") as f:
88
- return dict(tomlkit.load(f))
89
- except (OSError, TOMLKitError) as ex:
90
- console.error(f"Unable to read from pyproject.toml due to {ex}")
91
- if exit_on_fail:
92
- raise typer.Exit(code=1) from ex
93
- raise
94
-
95
-
96
74
  def _create_readme(module_name: str, package_name: str):
97
75
  """Create a package README file.
98
76
 
@@ -438,7 +416,9 @@ def _run_commands_in_subprocess(cmds: list[str]) -> bool:
438
416
 
439
417
  def _make_pyi_files():
440
418
  """Create pyi files for the custom component."""
441
- package_name = _get_package_config()["project"]["name"]
419
+ from glob import glob
420
+
421
+ package_name = glob("custom_components/*.egg-info")[0].replace(".egg-info", "")
442
422
 
443
423
  for dir, _, _ in os.walk(f"./{package_name}"):
444
424
  if "__pycache__" in dir:
@@ -534,10 +514,22 @@ def _validate_credentials(
534
514
  def _get_version_to_publish() -> str:
535
515
  """Get the version to publish from the pyproject.toml.
536
516
 
517
+ Raises:
518
+ Exit: If the version is not found in the pyproject.toml.
519
+
537
520
  Returns:
538
521
  The version to publish.
539
522
  """
540
- return _get_package_config()["project"]["version"]
523
+ # Get the version from the pyproject.toml.
524
+ try:
525
+ with open(CustomComponents.PYPROJECT_TOML, "rb") as f:
526
+ project_toml = tomlkit.parse(f.read())
527
+ return project_toml.get("project", {})["version"]
528
+ except (OSError, KeyError, TOMLKitError) as ex:
529
+ console.error(
530
+ f"Cannot find the version in {CustomComponents.PYPROJECT_TOML} due to {ex}"
531
+ )
532
+ raise typer.Exit(code=1) from ex
541
533
 
542
534
 
543
535
  def _ensure_dist_dir(version_to_publish: str, build: bool):
@@ -741,7 +733,12 @@ def _validate_project_info():
741
733
  Raises:
742
734
  Exit: If the pyproject.toml file is ill-formed.
743
735
  """
744
- pyproject_toml = _get_package_config()
736
+ try:
737
+ with open(CustomComponents.PYPROJECT_TOML, "rb") as f:
738
+ pyproject_toml = tomlkit.parse(f.read())
739
+ except TOMLKitError as ex:
740
+ console.error(f"Unable to read from pyproject.toml due to {ex}")
741
+ raise typer.Exit(code=1) from ex
745
742
 
746
743
  try:
747
744
  project = pyproject_toml.get("project", {})
@@ -799,7 +796,7 @@ def _validate_project_info():
799
796
  with open(CustomComponents.PYPROJECT_TOML, "w") as f:
800
797
  tomlkit.dump(pyproject_toml, f)
801
798
  except (OSError, TOMLKitError) as ex:
802
- console.error(f"Unable to write to pyproject.toml due to {ex}")
799
+ console.error(f"Unable to read from pyproject.toml due to {ex}")
803
800
  raise typer.Exit(code=1) from ex
804
801
 
805
802
 
@@ -819,8 +816,10 @@ def _collect_details_for_gallery():
819
816
  params = {}
820
817
  package_name = None
821
818
  try:
822
- package_name = _get_package_config(exit_on_fail=False)["project"]["name"]
823
- except (TOMLKitError, KeyError) as ex:
819
+ with open(CustomComponents.PYPROJECT_TOML, "rb") as f:
820
+ project_toml = tomlkit.parse(f.read())
821
+ package_name = project_toml.get("project", {})["name"]
822
+ except (OSError, TOMLKitError, KeyError) as ex:
824
823
  console.debug(
825
824
  f"Unable to read from pyproject.toml in current directory due to {ex}"
826
825
  )
@@ -851,6 +850,13 @@ def _collect_details_for_gallery():
851
850
  console.error(f"Unable to complete request due to {he}.")
852
851
  raise typer.Exit(code=1) from he
853
852
 
853
+ display_name = (
854
+ console.ask("[ Friendly display name for your component ] (enter to skip)")
855
+ or None
856
+ )
857
+ if display_name:
858
+ params["display_name"] = display_name
859
+
854
860
  files = []
855
861
  if (image_file_and_extension := _get_file_from_prompt_in_loop()) is not None:
856
862
  files.append(
@@ -856,16 +856,12 @@ def needs_reinit(frontend: bool = True) -> bool:
856
856
  )
857
857
  raise typer.Exit(1)
858
858
 
859
- # Don't need to reinit if not running in frontend mode.
860
- if not frontend:
861
- return False
862
-
863
859
  # Make sure the .reflex directory exists.
864
860
  if not os.path.exists(constants.Reflex.DIR):
865
861
  return True
866
862
 
867
863
  # Make sure the .web directory exists in frontend mode.
868
- if not os.path.exists(constants.Dirs.WEB):
864
+ if frontend and not os.path.exists(constants.Dirs.WEB):
869
865
  return True
870
866
 
871
867
  if constants.IS_WINDOWS:
reflex/utils/types.py CHANGED
@@ -416,12 +416,11 @@ def validate_literal(key: str, value: Any, expected_type: Type, comp_name: str):
416
416
  ):
417
417
  allowed_values = expected_type.__args__
418
418
  if value not in allowed_values:
419
- allowed_value_str = ",".join(
419
+ value_str = ",".join(
420
420
  [str(v) if not isinstance(v, str) else f"'{v}'" for v in allowed_values]
421
421
  )
422
- value_str = f"'{value}'" if isinstance(value, str) else value
423
422
  raise ValueError(
424
- f"prop value for {str(key)} of the `{comp_name}` component should be one of the following: {allowed_value_str}. Got {value_str} instead"
423
+ f"prop value for {str(key)} of the `{comp_name}` component should be one of the following: {value_str}. Got '{value}' instead"
425
424
  )
426
425
 
427
426
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflex
3
- Version: 0.4.7
3
+ Version: 0.4.7a2
4
4
  Summary: Web apps in pure Python.
5
5
  Home-page: https://reflex.dev
6
6
  License: Apache-2.0
@@ -470,7 +470,7 @@ reflex/constants/installer.py,sha256=wzoO_TaXF6N54CKmqpSSzT9QGIPalYn245AtUIIlEY0
470
470
  reflex/constants/route.py,sha256=9ydQEdlz3YwGmGMHVGz7zA-INoOLtz_xUU2S-WmhZZM,1940
471
471
  reflex/constants/style.py,sha256=gSzu0sQEQjW81PekxJnwRs7SXQQVco-LxtVjCi0IQZc,636
472
472
  reflex/custom_components/__init__.py,sha256=R4zsvOi4dfPmHc18KEphohXnQFBPnUCb50cMR5hSLDE,36
473
- reflex/custom_components/custom_components.py,sha256=Q2Ef3QvO3fheL-rcUF8g92xmY54UtJAHs7t_Dq1P65A,31705
473
+ reflex/custom_components/custom_components.py,sha256=bHTKFX2jLLhfW90Y-l3rpamyxhIqoqJrc127IUXEk7s,32096
474
474
  reflex/event.py,sha256=tQH1fLdBrTRI150VxiK6SbUBByPQxMNDylaSBYVliYM,26634
475
475
  reflex/experimental/__init__.py,sha256=nx9HxdZfYmCjR6LWbB6ms1Y_saZQWVQBUNSQAFs_F6s,287
476
476
  reflex/experimental/hooks.py,sha256=8LWdoq1aQPCA3ySDtlUzsPGiizM8CINvHUU6-ukZIFs,1647
@@ -493,17 +493,17 @@ reflex/utils/export.py,sha256=XzoJ9ipgT4jVOCy98XamdLv_99YI3-fE2FuVK9_HDiU,2357
493
493
  reflex/utils/format.py,sha256=4vY7NP-f7B2euJ5F5dM3yh5SYPzCY3bVZDATG2DMaMU,22648
494
494
  reflex/utils/imports.py,sha256=yah1kSVsOyUxA0wOMxJTwcmu6xlmkLJtV_zRIhshpsA,1919
495
495
  reflex/utils/path_ops.py,sha256=Vy6fU_bXvOcCvbXdTSmeLwy_C4h9seYU-3yIrVdZEZQ,4737
496
- reflex/utils/prerequisites.py,sha256=eZRuHKmUm59Hj_VEc91u3v8LJL6WGkmJDLpW2AXud8Y,45847
496
+ reflex/utils/prerequisites.py,sha256=lXdTgG0RSAQDoUkqSK8KXq9WoIiKTr_oI_m6-UiPhyk,45757
497
497
  reflex/utils/processes.py,sha256=SaDkqJVyhdyp5gE3Rn8MbU1VMNGN3BTObK5WWwqoEAE,8481
498
498
  reflex/utils/pyi_generator.py,sha256=VyGG0Tj3nvyBi2OQU-oscWRhJyRiYG9rUvJolKLK5Gg,27674
499
499
  reflex/utils/serializers.py,sha256=4LOCpri11NKVocnPb4zzgIBvW8fT-fX0h_1DIMfv5yI,8538
500
500
  reflex/utils/telemetry.py,sha256=NYAzPe7nU0EUwq2hIAByOzlie_5RhFlfHganBqG5OfA,4013
501
- reflex/utils/types.py,sha256=IUU7Gb6A_b-m1GbLb-fFhCp89YGddDgfCjSttF9od2c,13677
501
+ reflex/utils/types.py,sha256=-OT6RLGOfKnzlArNua7Kld6DLFeUFAasHS5B2RjLqsE,13585
502
502
  reflex/utils/watch.py,sha256=HzGrHQIZ_62Di0BO46kd2AZktNA3A6nFIBuf8c6ip30,2609
503
503
  reflex/vars.py,sha256=mef13GC4G_Iqicliyp6k9EWGULC1p1UewgM7gJODcBw,67152
504
504
  reflex/vars.pyi,sha256=7sVCLoLg9Y7QAmXWz6FCtVmScpSV84u0yQ3ZBImb_Bk,5583
505
- reflex-0.4.7.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
506
- reflex-0.4.7.dist-info/METADATA,sha256=YWbBojYwXsTkHnuSj9lyShlPqiaZf65NTGgG0vIH53I,11813
507
- reflex-0.4.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
508
- reflex-0.4.7.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
509
- reflex-0.4.7.dist-info/RECORD,,
505
+ reflex-0.4.7a2.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
506
+ reflex-0.4.7a2.dist-info/METADATA,sha256=0grbN1GJ6axc2z_EQzIU3TGoXawdnRUhtBEEZFBD5io,11815
507
+ reflex-0.4.7a2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
508
+ reflex-0.4.7a2.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
509
+ reflex-0.4.7a2.dist-info/RECORD,,