reflex 0.4.7a1__py3-none-any.whl → 0.4.7a3__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,6 +71,28 @@ 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
+
74
96
  def _create_readme(module_name: str, package_name: str):
75
97
  """Create a package README file.
76
98
 
@@ -416,9 +438,7 @@ def _run_commands_in_subprocess(cmds: list[str]) -> bool:
416
438
 
417
439
  def _make_pyi_files():
418
440
  """Create pyi files for the custom component."""
419
- from glob import glob
420
-
421
- package_name = glob("custom_components/*.egg-info")[0].replace(".egg-info", "")
441
+ package_name = _get_package_config()["project"]["name"]
422
442
 
423
443
  for dir, _, _ in os.walk(f"./{package_name}"):
424
444
  if "__pycache__" in dir:
@@ -514,22 +534,10 @@ def _validate_credentials(
514
534
  def _get_version_to_publish() -> str:
515
535
  """Get the version to publish from the pyproject.toml.
516
536
 
517
- Raises:
518
- Exit: If the version is not found in the pyproject.toml.
519
-
520
537
  Returns:
521
538
  The version to publish.
522
539
  """
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
540
+ return _get_package_config()["project"]["version"]
533
541
 
534
542
 
535
543
  def _ensure_dist_dir(version_to_publish: str, build: bool):
@@ -715,7 +723,7 @@ def publish(
715
723
  _collect_details_for_gallery()
716
724
 
717
725
 
718
- def _process_entered_list(input: str) -> list | None:
726
+ def _process_entered_list(input: str | None) -> list | None:
719
727
  """Process the user entered comma separated list into a list if applicable.
720
728
 
721
729
  Args:
@@ -724,7 +732,7 @@ def _process_entered_list(input: str) -> list | None:
724
732
  Returns:
725
733
  The list of items or None.
726
734
  """
727
- return [t.strip() for t in input.split(",") if t if input] or None
735
+ return [t.strip() for t in (input or "").split(",") if t if input] or None
728
736
 
729
737
 
730
738
  def _validate_project_info():
@@ -733,12 +741,7 @@ def _validate_project_info():
733
741
  Raises:
734
742
  Exit: If the pyproject.toml file is ill-formed.
735
743
  """
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
744
+ pyproject_toml = _get_package_config()
742
745
 
743
746
  try:
744
747
  project = pyproject_toml.get("project", {})
@@ -773,6 +776,7 @@ def _validate_project_info():
773
776
  )
774
777
  or []
775
778
  )
779
+ project["keywords"] = new_keywords
776
780
  elif keyword_action == "a":
777
781
  new_keywords = (
778
782
  _process_entered_list(
@@ -780,7 +784,7 @@ def _validate_project_info():
780
784
  )
781
785
  or []
782
786
  )
783
- project["keywords"] = project.get("keywords", []) + new_keywords
787
+ project["keywords"] = project.get("keywords", []) + new_keywords
784
788
 
785
789
  if not project.get("urls"):
786
790
  project["urls"] = {}
@@ -795,7 +799,7 @@ def _validate_project_info():
795
799
  with open(CustomComponents.PYPROJECT_TOML, "w") as f:
796
800
  tomlkit.dump(pyproject_toml, f)
797
801
  except (OSError, TOMLKitError) as ex:
798
- console.error(f"Unable to read from pyproject.toml due to {ex}")
802
+ console.error(f"Unable to write to pyproject.toml due to {ex}")
799
803
  raise typer.Exit(code=1) from ex
800
804
 
801
805
 
@@ -815,10 +819,8 @@ def _collect_details_for_gallery():
815
819
  params = {}
816
820
  package_name = None
817
821
  try:
818
- with open(CustomComponents.PYPROJECT_TOML, "rb") as f:
819
- project_toml = tomlkit.parse(f.read())
820
- package_name = project_toml.get("project", {})["name"]
821
- except (OSError, TOMLKitError, KeyError) as ex:
822
+ package_name = _get_package_config(exit_on_fail=False)["project"]["name"]
823
+ except (TOMLKitError, KeyError) as ex:
822
824
  console.debug(
823
825
  f"Unable to read from pyproject.toml in current directory due to {ex}"
824
826
  )
@@ -849,13 +851,6 @@ def _collect_details_for_gallery():
849
851
  console.error(f"Unable to complete request due to {he}.")
850
852
  raise typer.Exit(code=1) from he
851
853
 
852
- display_name = (
853
- console.ask("[ Friendly display name for your component ] (enter to skip)")
854
- or None
855
- )
856
- if display_name:
857
- params["display_name"] = display_name
858
-
859
854
  files = []
860
855
  if (image_file_and_extension := _get_file_from_prompt_in_loop()) is not None:
861
856
  files.append(
@@ -852,7 +852,7 @@ def needs_reinit(frontend: bool = True) -> bool:
852
852
  """
853
853
  if not os.path.exists(constants.Config.FILE):
854
854
  console.error(
855
- f"{constants.Config.FILE} not found. Run [bold]{constants.Reflex.MODULE_NAME} init[/bold] first."
855
+ f"[cyan]{constants.Config.FILE}[/cyan] not found. Move to the root folder of your project, or run [bold]{constants.Reflex.MODULE_NAME} init[/bold] to start a new project."
856
856
  )
857
857
  raise typer.Exit(1)
858
858
 
reflex/utils/types.py CHANGED
@@ -416,11 +416,12 @@ 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
- value_str = ",".join(
419
+ allowed_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
422
423
  raise ValueError(
423
- f"prop value for {str(key)} of the `{comp_name}` component should be one of the following: {value_str}. Got '{value}' instead"
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"
424
425
  )
425
426
 
426
427
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflex
3
- Version: 0.4.7a1
3
+ Version: 0.4.7a3
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=rqcEZxL4t8-B2khGuWioLpXNFQhiuUX4aq1PD9C3LbA,32034
473
+ reflex/custom_components/custom_components.py,sha256=Q2Ef3QvO3fheL-rcUF8g92xmY54UtJAHs7t_Dq1P65A,31705
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=Lmda9ATbLOxzPHZ_SCiFRLCtiGTIn-BhGb8sRsvJW1Y,45683
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=-OT6RLGOfKnzlArNua7Kld6DLFeUFAasHS5B2RjLqsE,13585
501
+ reflex/utils/types.py,sha256=IUU7Gb6A_b-m1GbLb-fFhCp89YGddDgfCjSttF9od2c,13677
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.7a1.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
506
- reflex-0.4.7a1.dist-info/METADATA,sha256=600bnM7UtydBTlimhydTvW8BBEhlwmHYxp9Iipf1_80,11815
507
- reflex-0.4.7a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
508
- reflex-0.4.7a1.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
509
- reflex-0.4.7a1.dist-info/RECORD,,
505
+ reflex-0.4.7a3.dist-info/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
506
+ reflex-0.4.7a3.dist-info/METADATA,sha256=xc8x1xNoBsrBroC1urtThDuxHm4guV0fxuqJ-GSnB8E,11815
507
+ reflex-0.4.7a3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
508
+ reflex-0.4.7a3.dist-info/entry_points.txt,sha256=H1Z5Yat_xJfy0dRT1Frk2PkO_p41Xy7fCKlj4FcdL9o,44
509
+ reflex-0.4.7a3.dist-info/RECORD,,