reflex 0.7.3a1__py3-none-any.whl → 0.7.4__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 (50) hide show
  1. reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +9 -1
  2. reflex/.templates/web/utils/state.js +1 -1
  3. reflex/app.py +21 -5
  4. reflex/app_mixins/middleware.py +2 -3
  5. reflex/base.py +3 -3
  6. reflex/compiler/compiler.py +68 -8
  7. reflex/components/component.py +6 -3
  8. reflex/components/core/client_side_routing.py +3 -3
  9. reflex/components/core/cond.py +20 -12
  10. reflex/components/core/upload.py +1 -1
  11. reflex/components/dynamic.py +2 -4
  12. reflex/components/lucide/icon.py +20 -27
  13. reflex/components/plotly/plotly.py +9 -9
  14. reflex/components/recharts/recharts.py +2 -2
  15. reflex/components/sonner/toast.py +1 -1
  16. reflex/config.py +23 -23
  17. reflex/constants/__init__.py +1 -2
  18. reflex/constants/base.py +3 -0
  19. reflex/constants/installer.py +8 -105
  20. reflex/custom_components/custom_components.py +8 -3
  21. reflex/reflex.py +22 -4
  22. reflex/state.py +9 -1
  23. reflex/testing.py +7 -1
  24. reflex/utils/build.py +3 -4
  25. reflex/utils/exec.py +156 -75
  26. reflex/utils/net.py +107 -18
  27. reflex/utils/path_ops.py +15 -25
  28. reflex/utils/prerequisites.py +225 -189
  29. reflex/utils/processes.py +70 -35
  30. reflex/utils/redir.py +3 -1
  31. reflex/utils/registry.py +16 -8
  32. reflex/vars/base.py +2 -38
  33. reflex/vars/datetime.py +10 -34
  34. reflex/vars/number.py +16 -112
  35. reflex/vars/sequence.py +99 -108
  36. {reflex-0.7.3a1.dist-info → reflex-0.7.4.dist-info}/METADATA +32 -23
  37. {reflex-0.7.3a1.dist-info → reflex-0.7.4.dist-info}/RECORD +58 -68
  38. {reflex-0.7.3a1.dist-info → reflex-0.7.4.dist-info}/WHEEL +1 -1
  39. {reflex-0.7.3a1.dist-info → reflex-0.7.4.dist-info}/entry_points.txt +0 -3
  40. benchmarks/__init__.py +0 -3
  41. benchmarks/benchmark_compile_times.py +0 -147
  42. benchmarks/benchmark_imports.py +0 -128
  43. benchmarks/benchmark_lighthouse.py +0 -75
  44. benchmarks/benchmark_package_size.py +0 -135
  45. benchmarks/benchmark_web_size.py +0 -106
  46. benchmarks/conftest.py +0 -20
  47. benchmarks/lighthouse.sh +0 -77
  48. benchmarks/utils.py +0 -74
  49. reflex/app_module_for_backend.py +0 -33
  50. {reflex-0.7.3a1.dist-info → reflex-0.7.4.dist-info}/licenses/LICENSE +0 -0
reflex/vars/sequence.py CHANGED
@@ -14,7 +14,6 @@ from typing import (
14
14
  List,
15
15
  Literal,
16
16
  Mapping,
17
- NoReturn,
18
17
  Sequence,
19
18
  Type,
20
19
  TypeVar,
@@ -76,13 +75,7 @@ VALUE_TYPE = TypeVar("VALUE_TYPE")
76
75
  class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
77
76
  """Base class for immutable array vars."""
78
77
 
79
- @overload
80
- def join(self, sep: StringVar | str = "") -> StringVar: ...
81
-
82
- @overload
83
- def join(self, sep: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
84
-
85
- def join(self, sep: Any = "") -> StringVar:
78
+ def join(self, sep: StringVar | str = "") -> StringVar:
86
79
  """Join the elements of the array.
87
80
 
88
81
  Args:
@@ -123,13 +116,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
123
116
  """
124
117
  return array_reverse_operation(self)
125
118
 
126
- @overload
127
- def __add__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> ArrayVar[ARRAY_VAR_TYPE]: ...
128
-
129
- @overload
130
- def __add__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
131
-
132
- def __add__(self, other: Any) -> ArrayVar[ARRAY_VAR_TYPE]:
119
+ def __add__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> ArrayVar[ARRAY_VAR_TYPE]:
133
120
  """Concatenate two arrays.
134
121
 
135
122
  Parameters:
@@ -352,13 +339,7 @@ class ArrayVar(Var[ARRAY_VAR_TYPE], python_types=(Sequence, set)):
352
339
  """
353
340
  return array_pluck_operation(self, field)
354
341
 
355
- @overload
356
- def __mul__(self, other: NumberVar | int) -> ArrayVar[ARRAY_VAR_TYPE]: ...
357
-
358
- @overload
359
- def __mul__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
360
-
361
- def __mul__(self, other: Any) -> ArrayVar[ARRAY_VAR_TYPE]:
342
+ def __mul__(self, other: NumberVar | int) -> ArrayVar[ARRAY_VAR_TYPE]:
362
343
  """Multiply the sequence by a number or integer.
363
344
 
364
345
  Parameters:
@@ -603,13 +584,7 @@ STRING_TYPE = TypingExtensionsTypeVar("STRING_TYPE", default=str)
603
584
  class StringVar(Var[STRING_TYPE], python_types=str):
604
585
  """Base class for immutable string vars."""
605
586
 
606
- @overload
607
- def __add__(self, other: StringVar | str) -> ConcatVarOperation: ...
608
-
609
- @overload
610
- def __add__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
611
-
612
- def __add__(self, other: Any) -> ConcatVarOperation:
587
+ def __add__(self, other: StringVar | str) -> ConcatVarOperation:
613
588
  """Concatenate two strings.
614
589
 
615
590
  Args:
@@ -623,13 +598,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
623
598
 
624
599
  return ConcatVarOperation.create(self, other)
625
600
 
626
- @overload
627
- def __radd__(self, other: StringVar | str) -> ConcatVarOperation: ...
628
-
629
- @overload
630
- def __radd__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
631
-
632
- def __radd__(self, other: Any) -> ConcatVarOperation:
601
+ def __radd__(self, other: StringVar | str) -> ConcatVarOperation:
633
602
  """Concatenate two strings.
634
603
 
635
604
  Args:
@@ -643,13 +612,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
643
612
 
644
613
  return ConcatVarOperation.create(other, self)
645
614
 
646
- @overload
647
- def __mul__(self, other: NumberVar | int) -> StringVar: ...
648
-
649
- @overload
650
- def __mul__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
651
-
652
- def __mul__(self, other: Any) -> StringVar:
615
+ def __mul__(self, other: NumberVar | int) -> StringVar:
653
616
  """Multiply the sequence by a number or an integer.
654
617
 
655
618
  Args:
@@ -663,13 +626,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
663
626
 
664
627
  return (self.split() * other).join()
665
628
 
666
- @overload
667
- def __rmul__(self, other: NumberVar | int) -> StringVar: ...
668
-
669
- @overload
670
- def __rmul__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
671
-
672
- def __rmul__(self, other: Any) -> StringVar:
629
+ def __rmul__(self, other: NumberVar | int) -> StringVar:
673
630
  """Multiply the sequence by a number or an integer.
674
631
 
675
632
  Args:
@@ -762,17 +719,9 @@ class StringVar(Var[STRING_TYPE], python_types=str):
762
719
  """
763
720
  return self.split().reverse().join()
764
721
 
765
- @overload
766
722
  def contains(
767
723
  self, other: StringVar | str, field: StringVar | str | None = None
768
- ) -> BooleanVar: ...
769
-
770
- @overload
771
- def contains( # pyright: ignore [reportOverlappingOverload]
772
- self, other: NoReturn, field: StringVar | str | None = None
773
- ) -> NoReturn: ...
774
-
775
- def contains(self, other: Any, field: Any = None) -> BooleanVar:
724
+ ) -> BooleanVar:
776
725
  """Check if the string contains another string.
777
726
 
778
727
  Args:
@@ -790,13 +739,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
790
739
  return string_contains_field_operation(self, other, field)
791
740
  return string_contains_operation(self, other)
792
741
 
793
- @overload
794
- def split(self, separator: StringVar | str = "") -> ArrayVar[list[str]]: ...
795
-
796
- @overload
797
- def split(self, separator: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
798
-
799
- def split(self, separator: Any = "") -> ArrayVar[list[str]]:
742
+ def split(self, separator: StringVar | str = "") -> ArrayVar[list[str]]:
800
743
  """Split the string.
801
744
 
802
745
  Args:
@@ -809,13 +752,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
809
752
  raise_unsupported_operand_types("split", (type(self), type(separator)))
810
753
  return string_split_operation(self, separator)
811
754
 
812
- @overload
813
- def startswith(self, prefix: StringVar | str) -> BooleanVar: ...
814
-
815
- @overload
816
- def startswith(self, prefix: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
817
-
818
- def startswith(self, prefix: Any) -> BooleanVar:
755
+ def startswith(self, prefix: StringVar | str) -> BooleanVar:
819
756
  """Check if the string starts with a prefix.
820
757
 
821
758
  Args:
@@ -828,13 +765,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
828
765
  raise_unsupported_operand_types("startswith", (type(self), type(prefix)))
829
766
  return string_starts_with_operation(self, prefix)
830
767
 
831
- @overload
832
- def endswith(self, suffix: StringVar | str) -> BooleanVar: ...
833
-
834
- @overload
835
- def endswith(self, suffix: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
836
-
837
- def endswith(self, suffix: Any) -> BooleanVar:
768
+ def endswith(self, suffix: StringVar | str) -> BooleanVar:
838
769
  """Check if the string ends with a suffix.
839
770
 
840
771
  Args:
@@ -847,13 +778,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
847
778
  raise_unsupported_operand_types("endswith", (type(self), type(suffix)))
848
779
  return string_ends_with_operation(self, suffix)
849
780
 
850
- @overload
851
- def __lt__(self, other: StringVar | str) -> BooleanVar: ...
852
-
853
- @overload
854
- def __lt__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
855
-
856
- def __lt__(self, other: Any):
781
+ def __lt__(self, other: StringVar | str) -> BooleanVar:
857
782
  """Check if the string is less than another string.
858
783
 
859
784
  Args:
@@ -867,13 +792,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
867
792
 
868
793
  return string_lt_operation(self, other)
869
794
 
870
- @overload
871
- def __gt__(self, other: StringVar | str) -> BooleanVar: ...
872
-
873
- @overload
874
- def __gt__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
875
-
876
- def __gt__(self, other: Any):
795
+ def __gt__(self, other: StringVar | str) -> BooleanVar:
877
796
  """Check if the string is greater than another string.
878
797
 
879
798
  Args:
@@ -887,13 +806,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
887
806
 
888
807
  return string_gt_operation(self, other)
889
808
 
890
- @overload
891
- def __le__(self, other: StringVar | str) -> BooleanVar: ...
892
-
893
- @overload
894
- def __le__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
895
-
896
- def __le__(self, other: Any):
809
+ def __le__(self, other: StringVar | str) -> BooleanVar:
897
810
  """Check if the string is less than or equal to another string.
898
811
 
899
812
  Args:
@@ -907,13 +820,7 @@ class StringVar(Var[STRING_TYPE], python_types=str):
907
820
 
908
821
  return string_le_operation(self, other)
909
822
 
910
- @overload
911
- def __ge__(self, other: StringVar | str) -> BooleanVar: ...
912
-
913
- @overload
914
- def __ge__(self, other: NoReturn) -> NoReturn: ... # pyright: ignore [reportOverlappingOverload]
915
-
916
- def __ge__(self, other: Any):
823
+ def __ge__(self, other: StringVar | str) -> BooleanVar:
917
824
  """Check if the string is greater than or equal to another string.
918
825
 
919
826
  Args:
@@ -1683,6 +1590,8 @@ def _determine_value_of_array_index(
1683
1590
  if t is not type(None)
1684
1591
  ]
1685
1592
  )
1593
+ if origin_var_type is range:
1594
+ return int
1686
1595
  if origin_var_type in [
1687
1596
  Sequence,
1688
1597
  Iterable,
@@ -1974,3 +1883,85 @@ class LiteralColorVar(CachedVarOperation, LiteralVar, ColorVar):
1974
1883
  ):
1975
1884
  raise TypeError("Color is not a valid color.")
1976
1885
  return f"var(--{color}-{'a' if alpha else ''}{shade})"
1886
+
1887
+
1888
+ class RangeVar(ArrayVar[Sequence[int]], python_types=range):
1889
+ """Base class for immutable range vars."""
1890
+
1891
+
1892
+ @dataclasses.dataclass(
1893
+ eq=False,
1894
+ frozen=True,
1895
+ slots=True,
1896
+ )
1897
+ class LiteralRangeVar(CachedVarOperation, LiteralVar, RangeVar):
1898
+ """Base class for immutable literal range vars."""
1899
+
1900
+ _var_value: range = dataclasses.field(default_factory=lambda: range(0))
1901
+
1902
+ @classmethod
1903
+ def create(
1904
+ cls,
1905
+ value: range,
1906
+ _var_type: Type[range] | None = None,
1907
+ _var_data: VarData | None = None,
1908
+ ) -> RangeVar:
1909
+ """Create a var from a string value.
1910
+
1911
+ Args:
1912
+ value: The value to create the var from.
1913
+ _var_type: The type of the var.
1914
+ _var_data: Additional hooks and imports associated with the Var.
1915
+
1916
+ Returns:
1917
+ The var.
1918
+ """
1919
+ return cls(
1920
+ _js_expr="",
1921
+ _var_type=_var_type or range,
1922
+ _var_data=_var_data,
1923
+ _var_value=value,
1924
+ )
1925
+
1926
+ def __hash__(self) -> int:
1927
+ """Get the hash of the var.
1928
+
1929
+ Returns:
1930
+ The hash of the var.
1931
+ """
1932
+ return hash(
1933
+ (
1934
+ self.__class__.__name__,
1935
+ self._var_value.start,
1936
+ self._var_value.stop,
1937
+ self._var_value.step,
1938
+ )
1939
+ )
1940
+
1941
+ @cached_property_no_lock
1942
+ def _cached_var_name(self) -> str:
1943
+ """The name of the var.
1944
+
1945
+ Returns:
1946
+ The name of the var.
1947
+ """
1948
+ return f"Array.from({{ length: Math.ceil(({self._var_value.stop!s} - {self._var_value.start!s}) / {self._var_value.step!s}) }}, (_, i) => {self._var_value.start!s} + i * {self._var_value.step!s})"
1949
+
1950
+ @cached_property_no_lock
1951
+ def _cached_get_all_var_data(self) -> VarData | None:
1952
+ """Get all the var data.
1953
+
1954
+ Returns:
1955
+ The var data.
1956
+ """
1957
+ return self._var_data
1958
+
1959
+ def json(self) -> str:
1960
+ """Get the JSON representation of the var.
1961
+
1962
+ Returns:
1963
+ The JSON representation of the var.
1964
+ """
1965
+ return json.dumps(
1966
+ list(self._var_value),
1967
+ )
@@ -1,45 +1,53 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reflex
3
- Version: 0.7.3a1
3
+ Version: 0.7.4
4
4
  Summary: Web apps in pure Python.
5
- Keywords: web,framework
6
- Author: Elijah Ahianyo
7
- Author-Email: Nikhil Rao <nikhil@reflex.dev>, Alek Petuskey <alek@reflex.dev>, Masen Furer <masen@reflex.dev>, =?utf-8?q?Thomas_Brand=C3=A9ho?= <thomas@reflex.dev>, Khaleel Al-Adhami <khaleel@reflex.dev>
8
- Maintainer-Email: Masen Furer <masen@reflex.dev>, =?utf-8?q?Thomas_Brand=C3=A9ho?= <thomas@reflex.dev>, Khaleel Al-Adhami <khaleel@reflex.dev>
9
- License-Expression: Apache-2.0
10
5
  Project-URL: homepage, https://reflex.dev
11
6
  Project-URL: repository, https://github.com/reflex-dev/reflex
12
7
  Project-URL: documentation, https://reflex.dev/docs/getting-started/introduction
8
+ Author-email: Nikhil Rao <nikhil@reflex.dev>, Alek Petuskey <alek@reflex.dev>, Masen Furer <masen@reflex.dev>, Elijah Ahianyo <elijahahianyo@gmail.com>, Thomas Brandeho <thomas@reflex.dev>, Khaleel Al-Adhami <khaleel@reflex.dev>
9
+ Maintainer-email: Masen Furer <masen@reflex.dev>, Thomas Brandeho <thomas@reflex.dev>, Khaleel Al-Adhami <khaleel@reflex.dev>
10
+ License: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: framework,web
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
13
20
  Requires-Python: <4.0,>=3.10
21
+ Requires-Dist: alembic<2.0,>=1.11.1
22
+ Requires-Dist: build<2.0,>=1.0.3
23
+ Requires-Dist: charset-normalizer<4.0,>=3.3.2
24
+ Requires-Dist: distro<2.0,>=1.8.0; platform_system == 'Linux'
14
25
  Requires-Dist: fastapi!=0.111.0,!=0.111.1,>=0.96.0
15
- Requires-Dist: gunicorn<24.0,>=20.1.0
26
+ Requires-Dist: granian[reload]>=2.0.0
27
+ Requires-Dist: gunicorn<24.0.0,>=23.0.0
28
+ Requires-Dist: httpx<1.0,>=0.25.1
16
29
  Requires-Dist: jinja2<4.0,>=3.1.2
30
+ Requires-Dist: lazy-loader>=0.4
31
+ Requires-Dist: packaging<25.0,>=23.1
32
+ Requires-Dist: platformdirs<5.0,>=3.10.0
17
33
  Requires-Dist: psutil<8.0,>=5.9.4
18
34
  Requires-Dist: pydantic<3.0,>=1.10.21
35
+ Requires-Dist: python-engineio!=4.6.0
19
36
  Requires-Dist: python-multipart<0.1,>=0.0.5
20
37
  Requires-Dist: python-socketio<6.0,>=5.7.0
21
38
  Requires-Dist: redis<6.0,>=4.3.5
39
+ Requires-Dist: reflex-hosting-cli>=0.1.29
22
40
  Requires-Dist: rich<14.0,>=13.0.0
41
+ Requires-Dist: setuptools>=75.0
23
42
  Requires-Dist: sqlmodel<0.1,>=0.0.14
43
+ Requires-Dist: starlette-admin<1.0,>=0.11.0
44
+ Requires-Dist: tomlkit<1.0,>=0.12.4
45
+ Requires-Dist: twine<7.0,>=4.0.0
24
46
  Requires-Dist: typer<1.0,>=0.15.1
47
+ Requires-Dist: typing-extensions>=4.6.0
25
48
  Requires-Dist: uvicorn>=0.20.0
26
- Requires-Dist: starlette-admin<1.0,>=0.11.0
27
- Requires-Dist: alembic<2.0,>=1.11.1
28
- Requires-Dist: platformdirs<5.0,>=3.10.0
29
- Requires-Dist: distro<2.0,>=1.8.0; platform_system == "Linux"
30
- Requires-Dist: python-engineio!=4.6.0
31
- Requires-Dist: wrapt<2.0,>=1.17.0
32
- Requires-Dist: packaging<25.0,>=23.1
33
- Requires-Dist: reflex-hosting-cli>=0.1.29
34
- Requires-Dist: charset-normalizer<4.0,>=3.3.2
35
49
  Requires-Dist: wheel<1.0,>=0.42.0
36
- Requires-Dist: build<2.0,>=1.0.3
37
- Requires-Dist: setuptools>=75.0
38
- Requires-Dist: httpx<1.0,>=0.25.1
39
- Requires-Dist: twine<7.0,>=4.0.0
40
- Requires-Dist: tomlkit<1.0,>=0.12.4
41
- Requires-Dist: lazy_loader>=0.4
42
- Requires-Dist: typing_extensions>=4.6.0
50
+ Requires-Dist: wrapt<2.0,>=1.17.0
43
51
  Description-Content-Type: text/markdown
44
52
 
45
53
  <div align="center">
@@ -53,6 +61,7 @@ Description-Content-Type: text/markdown
53
61
  [![PyPI version](https://badge.fury.io/py/reflex.svg)](https://badge.fury.io/py/reflex)
54
62
  ![versions](https://img.shields.io/pypi/pyversions/reflex.svg)
55
63
  [![Documentation](https://img.shields.io/badge/Documentation%20-Introduction%20-%20%23007ec6)](https://reflex.dev/docs/getting-started/introduction)
64
+ [![PyPI Downloads](https://static.pepy.tech/badge/reflex)](https://pepy.tech/projects/reflex)
56
65
  [![Discord](https://img.shields.io/discord/1029853095527727165?color=%237289da&label=Discord)](https://discord.gg/T5WSbC2YtQ)
57
66
 
58
67
  </div>