reflex 0.6.8a1__py3-none-any.whl → 0.7.0__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/.templates/jinja/custom_components/pyproject.toml.jinja2 +1 -1
- reflex/.templates/jinja/web/pages/_app.js.jinja2 +7 -7
- reflex/.templates/jinja/web/pages/utils.js.jinja2 +3 -3
- reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +1 -4
- reflex/.templates/web/utils/state.js +65 -36
- reflex/__init__.py +4 -17
- reflex/__init__.pyi +1 -2
- reflex/app.py +286 -135
- reflex/app_mixins/lifespan.py +9 -9
- reflex/app_mixins/middleware.py +6 -6
- reflex/app_module_for_backend.py +3 -7
- reflex/base.py +7 -7
- reflex/compiler/compiler.py +8 -0
- reflex/compiler/utils.py +57 -18
- reflex/components/base/app_wrap.pyi +16 -16
- reflex/components/base/bare.py +1 -1
- reflex/components/base/body.pyi +16 -16
- reflex/components/base/document.pyi +76 -76
- reflex/components/base/error_boundary.py +2 -1
- reflex/components/base/error_boundary.pyi +19 -22
- reflex/components/base/fragment.pyi +16 -16
- reflex/components/base/head.pyi +31 -31
- reflex/components/base/link.pyi +31 -31
- reflex/components/base/meta.py +2 -2
- reflex/components/base/meta.pyi +61 -61
- reflex/components/base/script.pyi +19 -19
- reflex/components/base/strict_mode.py +10 -0
- reflex/components/base/strict_mode.pyi +57 -0
- reflex/components/component.py +38 -77
- reflex/components/core/banner.py +159 -4
- reflex/components/core/banner.pyi +162 -76
- reflex/components/core/breakpoints.py +3 -1
- reflex/components/core/client_side_routing.py +1 -1
- reflex/components/core/client_side_routing.pyi +32 -32
- reflex/components/core/clipboard.pyi +17 -20
- reflex/components/core/cond.py +9 -10
- reflex/components/core/debounce.py +1 -1
- reflex/components/core/debounce.pyi +17 -17
- reflex/components/core/foreach.py +28 -3
- reflex/components/core/html.py +1 -1
- reflex/components/core/html.pyi +16 -16
- reflex/components/core/match.py +5 -5
- reflex/components/core/sticky.py +134 -0
- reflex/components/core/sticky.pyi +449 -0
- reflex/components/core/upload.py +2 -2
- reflex/components/core/upload.pyi +80 -88
- reflex/components/datadisplay/code.py +5 -14
- reflex/components/datadisplay/code.pyi +31 -31
- reflex/components/datadisplay/dataeditor.py +7 -4
- reflex/components/datadisplay/dataeditor.pyi +40 -54
- reflex/components/datadisplay/logo.py +13 -8
- reflex/components/datadisplay/shiki_code_block.py +14 -9
- reflex/components/datadisplay/shiki_code_block.pyi +46 -46
- reflex/components/dynamic.py +22 -3
- reflex/components/el/constants/reflex.py +1 -1
- reflex/components/el/element.py +1 -1
- reflex/components/el/element.pyi +16 -16
- reflex/components/el/elements/base.pyi +16 -16
- reflex/components/el/elements/forms.py +4 -4
- reflex/components/el/elements/forms.pyi +224 -258
- reflex/components/el/elements/inline.pyi +421 -421
- reflex/components/el/elements/media.pyi +376 -376
- reflex/components/el/elements/metadata.pyi +91 -91
- reflex/components/el/elements/other.pyi +106 -106
- reflex/components/el/elements/scripts.pyi +46 -46
- reflex/components/el/elements/sectioning.pyi +226 -226
- reflex/components/el/elements/tables.pyi +151 -151
- reflex/components/el/elements/typography.pyi +226 -226
- reflex/components/gridjs/datatable.pyi +31 -31
- reflex/components/lucide/icon.py +46 -8
- reflex/components/lucide/icon.pyi +85 -31
- reflex/components/markdown/markdown.py +10 -8
- reflex/components/markdown/markdown.pyi +16 -16
- reflex/components/moment/moment.py +2 -2
- reflex/components/moment/moment.pyi +17 -19
- reflex/components/next/base.pyi +16 -16
- reflex/components/next/image.py +16 -4
- reflex/components/next/image.pyi +22 -20
- reflex/components/next/link.py +1 -1
- reflex/components/next/link.pyi +16 -16
- reflex/components/next/video.pyi +16 -16
- reflex/components/plotly/__init__.py +29 -2
- reflex/components/plotly/plotly.py +240 -5
- reflex/components/plotly/plotly.pyi +799 -44
- reflex/components/props.py +3 -3
- reflex/components/radix/__init__.pyi +1 -1
- reflex/components/radix/primitives/accordion.py +9 -5
- reflex/components/radix/primitives/accordion.pyi +110 -108
- reflex/components/radix/primitives/base.pyi +31 -31
- reflex/components/radix/primitives/drawer.py +5 -2
- reflex/components/radix/primitives/drawer.pyi +179 -187
- reflex/components/radix/primitives/form.pyi +160 -172
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/progress.pyi +76 -76
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/primitives/slider.pyi +78 -82
- reflex/components/radix/themes/base.pyi +121 -121
- reflex/components/radix/themes/color_mode.py +11 -9
- reflex/components/radix/themes/color_mode.pyi +47 -49
- reflex/components/radix/themes/components/alert_dialog.py +3 -0
- reflex/components/radix/themes/components/alert_dialog.pyi +110 -112
- reflex/components/radix/themes/components/aspect_ratio.pyi +16 -16
- reflex/components/radix/themes/components/avatar.pyi +16 -16
- reflex/components/radix/themes/components/badge.pyi +16 -16
- reflex/components/radix/themes/components/button.pyi +16 -16
- reflex/components/radix/themes/components/callout.pyi +76 -76
- reflex/components/radix/themes/components/card.py +1 -1
- reflex/components/radix/themes/components/card.pyi +17 -17
- reflex/components/radix/themes/components/checkbox.pyi +49 -55
- reflex/components/radix/themes/components/checkbox_cards.pyi +31 -31
- reflex/components/radix/themes/components/checkbox_group.pyi +31 -31
- reflex/components/radix/themes/components/context_menu.py +5 -0
- reflex/components/radix/themes/components/context_menu.pyi +149 -155
- reflex/components/radix/themes/components/data_list.pyi +61 -61
- reflex/components/radix/themes/components/dialog.py +3 -0
- reflex/components/radix/themes/components/dialog.pyi +113 -117
- reflex/components/radix/themes/components/dropdown_menu.py +5 -0
- reflex/components/radix/themes/components/dropdown_menu.pyi +133 -137
- reflex/components/radix/themes/components/hover_card.py +3 -0
- reflex/components/radix/themes/components/hover_card.pyi +63 -67
- reflex/components/radix/themes/components/icon_button.py +2 -2
- reflex/components/radix/themes/components/icon_button.pyi +17 -16
- reflex/components/radix/themes/components/inset.pyi +16 -16
- reflex/components/radix/themes/components/popover.py +3 -0
- reflex/components/radix/themes/components/popover.pyi +68 -70
- reflex/components/radix/themes/components/progress.pyi +16 -16
- reflex/components/radix/themes/components/radio.pyi +16 -16
- reflex/components/radix/themes/components/radio_cards.py +2 -0
- reflex/components/radix/themes/components/radio_cards.pyi +32 -34
- reflex/components/radix/themes/components/radio_group.py +1 -1
- reflex/components/radix/themes/components/radio_group.pyi +62 -64
- reflex/components/radix/themes/components/scroll_area.pyi +16 -16
- reflex/components/radix/themes/components/segmented_control.pyi +32 -35
- reflex/components/radix/themes/components/select.py +4 -0
- reflex/components/radix/themes/components/select.pyi +145 -157
- reflex/components/radix/themes/components/separator.pyi +16 -16
- reflex/components/radix/themes/components/skeleton.py +3 -0
- reflex/components/radix/themes/components/skeleton.pyi +16 -16
- reflex/components/radix/themes/components/slider.pyi +22 -28
- reflex/components/radix/themes/components/spinner.pyi +16 -16
- reflex/components/radix/themes/components/switch.pyi +17 -19
- reflex/components/radix/themes/components/table.pyi +106 -106
- reflex/components/radix/themes/components/tabs.py +3 -0
- reflex/components/radix/themes/components/tabs.pyi +78 -82
- reflex/components/radix/themes/components/text_area.py +12 -0
- reflex/components/radix/themes/components/text_area.pyi +21 -33
- reflex/components/radix/themes/components/text_field.py +1 -1
- reflex/components/radix/themes/components/text_field.pyi +52 -80
- reflex/components/radix/themes/components/tooltip.py +6 -1
- reflex/components/radix/themes/components/tooltip.pyi +20 -21
- reflex/components/radix/themes/layout/__init__.pyi +1 -1
- reflex/components/radix/themes/layout/base.pyi +16 -16
- reflex/components/radix/themes/layout/box.pyi +16 -16
- reflex/components/radix/themes/layout/center.pyi +16 -16
- reflex/components/radix/themes/layout/container.pyi +16 -16
- reflex/components/radix/themes/layout/flex.pyi +16 -16
- reflex/components/radix/themes/layout/grid.pyi +16 -16
- reflex/components/radix/themes/layout/list.py +2 -2
- reflex/components/radix/themes/layout/list.pyi +76 -76
- reflex/components/radix/themes/layout/section.pyi +16 -16
- reflex/components/radix/themes/layout/spacer.pyi +16 -16
- reflex/components/radix/themes/layout/stack.py +2 -2
- reflex/components/radix/themes/layout/stack.pyi +46 -46
- reflex/components/radix/themes/typography/blockquote.pyi +16 -16
- reflex/components/radix/themes/typography/code.pyi +16 -16
- reflex/components/radix/themes/typography/heading.pyi +16 -16
- reflex/components/radix/themes/typography/link.py +1 -1
- reflex/components/radix/themes/typography/link.pyi +16 -16
- reflex/components/radix/themes/typography/text.py +2 -2
- reflex/components/radix/themes/typography/text.pyi +106 -106
- reflex/components/react_player/audio.pyi +33 -39
- reflex/components/react_player/react_player.py +1 -1
- reflex/components/react_player/react_player.pyi +32 -38
- reflex/components/react_player/video.pyi +33 -39
- reflex/components/recharts/__init__.py +2 -0
- reflex/components/recharts/__init__.pyi +2 -0
- reflex/components/recharts/cartesian.pyi +282 -282
- reflex/components/recharts/charts.py +15 -15
- reflex/components/recharts/charts.pyi +164 -164
- reflex/components/recharts/general.py +19 -4
- reflex/components/recharts/general.pyi +132 -81
- reflex/components/recharts/polar.py +2 -2
- reflex/components/recharts/polar.pyi +55 -55
- reflex/components/recharts/recharts.py +4 -4
- reflex/components/recharts/recharts.pyi +31 -31
- reflex/components/sonner/toast.py +15 -13
- reflex/components/sonner/toast.pyi +22 -22
- reflex/components/suneditor/editor.py +6 -4
- reflex/components/suneditor/editor.pyi +26 -40
- reflex/components/tags/iter_tag.py +3 -3
- reflex/components/tags/tag.py +25 -3
- reflex/config.py +48 -20
- reflex/constants/__init__.py +1 -0
- reflex/constants/base.py +4 -1
- reflex/constants/compiler.py +5 -2
- reflex/constants/config.py +8 -1
- reflex/constants/installer.py +9 -9
- reflex/constants/style.py +1 -1
- reflex/custom_components/custom_components.py +18 -10
- reflex/event.py +228 -233
- reflex/experimental/__init__.py +19 -11
- reflex/experimental/client_state.py +53 -28
- reflex/experimental/hooks.py +5 -5
- reflex/experimental/layout.py +8 -5
- reflex/experimental/layout.pyi +79 -83
- reflex/experimental/misc.py +3 -3
- reflex/istate/wrappers.py +1 -1
- reflex/middleware/hydrate_middleware.py +2 -2
- reflex/model.py +11 -6
- reflex/page.py +5 -5
- reflex/reflex.py +104 -26
- reflex/route.py +1 -1
- reflex/state.py +358 -401
- reflex/style.py +27 -3
- reflex/testing.py +34 -39
- reflex/utils/build.py +6 -2
- reflex/utils/codespaces.py +1 -4
- reflex/utils/compat.py +6 -5
- reflex/utils/console.py +71 -21
- reflex/utils/exceptions.py +89 -26
- reflex/utils/exec.py +69 -74
- reflex/utils/export.py +6 -1
- reflex/utils/format.py +8 -40
- reflex/utils/imports.py +5 -2
- reflex/utils/lazy_loader.py +7 -1
- reflex/utils/path_ops.py +74 -14
- reflex/utils/prerequisites.py +345 -68
- reflex/utils/processes.py +45 -32
- reflex/utils/pyi_generator.py +39 -33
- reflex/utils/registry.py +4 -4
- reflex/utils/serializers.py +1 -1
- reflex/utils/telemetry.py +5 -4
- reflex/utils/types.py +42 -18
- reflex/vars/base.py +695 -330
- reflex/vars/datetime.py +6 -7
- reflex/vars/dep_tracking.py +344 -0
- reflex/vars/function.py +11 -5
- reflex/vars/number.py +31 -43
- reflex/vars/object.py +74 -64
- reflex/vars/sequence.py +79 -67
- {reflex-0.6.8a1.dist-info → reflex-0.7.0.dist-info}/METADATA +7 -10
- reflex-0.7.0.dist-info/RECORD +401 -0
- {reflex-0.6.8a1.dist-info → reflex-0.7.0.dist-info}/WHEEL +1 -1
- reflex/experimental/assets.py +0 -37
- reflex/proxy.py +0 -119
- reflex-0.6.8a1.dist-info/RECORD +0 -398
- {reflex-0.6.8a1.dist-info → reflex-0.7.0.dist-info}/LICENSE +0 -0
- {reflex-0.6.8a1.dist-info → reflex-0.7.0.dist-info}/entry_points.txt +0 -0
reflex/utils/types.py
CHANGED
|
@@ -24,7 +24,7 @@ from typing import (
|
|
|
24
24
|
Tuple,
|
|
25
25
|
Type,
|
|
26
26
|
Union,
|
|
27
|
-
_GenericAlias, #
|
|
27
|
+
_GenericAlias, # pyright: ignore [reportAttributeAccessIssue]
|
|
28
28
|
get_args,
|
|
29
29
|
get_type_hints,
|
|
30
30
|
)
|
|
@@ -39,7 +39,9 @@ from reflex.components.core.breakpoints import Breakpoints
|
|
|
39
39
|
try:
|
|
40
40
|
from pydantic.v1.fields import ModelField
|
|
41
41
|
except ModuleNotFoundError:
|
|
42
|
-
from pydantic.fields import
|
|
42
|
+
from pydantic.fields import (
|
|
43
|
+
ModelField, # pyright: ignore [reportAttributeAccessIssue]
|
|
44
|
+
)
|
|
43
45
|
|
|
44
46
|
from sqlalchemy.ext.associationproxy import AssociationProxyInstance
|
|
45
47
|
from sqlalchemy.ext.hybrid import hybrid_property
|
|
@@ -70,13 +72,15 @@ GenericAliasTypes = [_GenericAlias]
|
|
|
70
72
|
|
|
71
73
|
with contextlib.suppress(ImportError):
|
|
72
74
|
# For newer versions of Python.
|
|
73
|
-
from types import GenericAlias
|
|
75
|
+
from types import GenericAlias
|
|
74
76
|
|
|
75
77
|
GenericAliasTypes.append(GenericAlias)
|
|
76
78
|
|
|
77
79
|
with contextlib.suppress(ImportError):
|
|
78
80
|
# For older versions of Python.
|
|
79
|
-
from typing import
|
|
81
|
+
from typing import (
|
|
82
|
+
_SpecialGenericAlias, # pyright: ignore [reportAttributeAccessIssue]
|
|
83
|
+
)
|
|
80
84
|
|
|
81
85
|
GenericAliasTypes.append(_SpecialGenericAlias)
|
|
82
86
|
|
|
@@ -153,7 +157,7 @@ class Unset:
|
|
|
153
157
|
|
|
154
158
|
|
|
155
159
|
@lru_cache()
|
|
156
|
-
def get_origin(tp):
|
|
160
|
+
def get_origin(tp: Any):
|
|
157
161
|
"""Get the origin of a class.
|
|
158
162
|
|
|
159
163
|
Args:
|
|
@@ -175,7 +179,7 @@ def is_generic_alias(cls: GenericType) -> bool:
|
|
|
175
179
|
Returns:
|
|
176
180
|
Whether the class is a generic alias.
|
|
177
181
|
"""
|
|
178
|
-
return isinstance(cls, GenericAliasTypes)
|
|
182
|
+
return isinstance(cls, GenericAliasTypes) # pyright: ignore [reportArgumentType]
|
|
179
183
|
|
|
180
184
|
|
|
181
185
|
def unionize(*args: GenericType) -> Type:
|
|
@@ -188,14 +192,14 @@ def unionize(*args: GenericType) -> Type:
|
|
|
188
192
|
The unionized types.
|
|
189
193
|
"""
|
|
190
194
|
if not args:
|
|
191
|
-
return Any
|
|
195
|
+
return Any # pyright: ignore [reportReturnType]
|
|
192
196
|
if len(args) == 1:
|
|
193
197
|
return args[0]
|
|
194
198
|
# We are bisecting the args list here to avoid hitting the recursion limit
|
|
195
199
|
# In Python versions >= 3.11, we can simply do `return Union[*args]`
|
|
196
200
|
midpoint = len(args) // 2
|
|
197
201
|
first_half, second_half = args[:midpoint], args[midpoint:]
|
|
198
|
-
return Union[unionize(*first_half), unionize(*second_half)]
|
|
202
|
+
return Union[unionize(*first_half), unionize(*second_half)] # pyright: ignore [reportReturnType]
|
|
199
203
|
|
|
200
204
|
|
|
201
205
|
def is_none(cls: GenericType) -> bool:
|
|
@@ -236,7 +240,7 @@ def is_literal(cls: GenericType) -> bool:
|
|
|
236
240
|
return get_origin(cls) is Literal
|
|
237
241
|
|
|
238
242
|
|
|
239
|
-
def has_args(cls) -> bool:
|
|
243
|
+
def has_args(cls: Type) -> bool:
|
|
240
244
|
"""Check if the class has generic parameters.
|
|
241
245
|
|
|
242
246
|
Args:
|
|
@@ -351,13 +355,13 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None
|
|
|
351
355
|
if type_ is not None:
|
|
352
356
|
if hasattr(column_type, "item_type"):
|
|
353
357
|
try:
|
|
354
|
-
item_type = column_type.item_type.python_type #
|
|
358
|
+
item_type = column_type.item_type.python_type # pyright: ignore [reportAttributeAccessIssue]
|
|
355
359
|
except NotImplementedError:
|
|
356
360
|
item_type = None
|
|
357
361
|
if item_type is not None:
|
|
358
362
|
if type_ in PrimitiveToAnnotation:
|
|
359
|
-
type_ = PrimitiveToAnnotation[type_]
|
|
360
|
-
type_ = type_[item_type] #
|
|
363
|
+
type_ = PrimitiveToAnnotation[type_]
|
|
364
|
+
type_ = type_[item_type] # pyright: ignore [reportIndexIssue]
|
|
361
365
|
if column.nullable:
|
|
362
366
|
type_ = Optional[type_]
|
|
363
367
|
return type_
|
|
@@ -432,7 +436,7 @@ def get_base_class(cls: GenericType) -> Type:
|
|
|
432
436
|
return type(get_args(cls)[0])
|
|
433
437
|
|
|
434
438
|
if is_union(cls):
|
|
435
|
-
return tuple(get_base_class(arg) for arg in get_args(cls))
|
|
439
|
+
return tuple(get_base_class(arg) for arg in get_args(cls)) # pyright: ignore [reportReturnType]
|
|
436
440
|
|
|
437
441
|
return get_base_class(cls.__origin__) if is_generic_alias(cls) else cls
|
|
438
442
|
|
|
@@ -605,7 +609,9 @@ def _isinstance(obj: Any, cls: GenericType, nested: bool = False) -> bool:
|
|
|
605
609
|
return (
|
|
606
610
|
isinstance(obj, tuple)
|
|
607
611
|
and len(obj) == len(args)
|
|
608
|
-
and all(
|
|
612
|
+
and all(
|
|
613
|
+
_isinstance(item, arg) for item, arg in zip(obj, args, strict=True)
|
|
614
|
+
)
|
|
609
615
|
)
|
|
610
616
|
if origin in (dict, Breakpoints):
|
|
611
617
|
return isinstance(obj, dict) and all(
|
|
@@ -747,7 +753,7 @@ def check_prop_in_allowed_types(prop: Any, allowed_types: Iterable) -> bool:
|
|
|
747
753
|
return type_ in allowed_types
|
|
748
754
|
|
|
749
755
|
|
|
750
|
-
def is_encoded_fstring(value) -> bool:
|
|
756
|
+
def is_encoded_fstring(value: Any) -> bool:
|
|
751
757
|
"""Check if a value is an encoded Var f-string.
|
|
752
758
|
|
|
753
759
|
Args:
|
|
@@ -790,7 +796,7 @@ def validate_literal(key: str, value: Any, expected_type: Type, comp_name: str):
|
|
|
790
796
|
)
|
|
791
797
|
|
|
792
798
|
|
|
793
|
-
def validate_parameter_literals(func):
|
|
799
|
+
def validate_parameter_literals(func: Callable):
|
|
794
800
|
"""Decorator to check that the arguments passed to a function
|
|
795
801
|
correspond to the correct function parameter if it (the parameter)
|
|
796
802
|
is a literal type.
|
|
@@ -808,7 +814,7 @@ def validate_parameter_literals(func):
|
|
|
808
814
|
annotations = {param[0]: param[1].annotation for param in func_params}
|
|
809
815
|
|
|
810
816
|
# validate args
|
|
811
|
-
for param, arg in zip(annotations, args):
|
|
817
|
+
for param, arg in zip(annotations, args, strict=False):
|
|
812
818
|
if annotations[param] is inspect.Parameter.empty:
|
|
813
819
|
continue
|
|
814
820
|
validate_literal(param, arg, annotations[param], func.__name__)
|
|
@@ -829,6 +835,22 @@ StateBases = get_base_class(StateVar)
|
|
|
829
835
|
StateIterBases = get_base_class(StateIterVar)
|
|
830
836
|
|
|
831
837
|
|
|
838
|
+
def safe_issubclass(cls: Type, cls_check: Type | Tuple[Type, ...]):
|
|
839
|
+
"""Check if a class is a subclass of another class. Returns False if internal error occurs.
|
|
840
|
+
|
|
841
|
+
Args:
|
|
842
|
+
cls: The class to check.
|
|
843
|
+
cls_check: The class to check against.
|
|
844
|
+
|
|
845
|
+
Returns:
|
|
846
|
+
Whether the class is a subclass of the other class.
|
|
847
|
+
"""
|
|
848
|
+
try:
|
|
849
|
+
return issubclass(cls, cls_check)
|
|
850
|
+
except TypeError:
|
|
851
|
+
return False
|
|
852
|
+
|
|
853
|
+
|
|
832
854
|
def typehint_issubclass(possible_subclass: Any, possible_superclass: Any) -> bool:
|
|
833
855
|
"""Check if a type hint is a subclass of another type hint.
|
|
834
856
|
|
|
@@ -890,6 +912,8 @@ def typehint_issubclass(possible_subclass: Any, possible_superclass: Any) -> boo
|
|
|
890
912
|
# It also ignores when the length of the arguments is different
|
|
891
913
|
return all(
|
|
892
914
|
typehint_issubclass(provided_arg, accepted_arg)
|
|
893
|
-
for provided_arg, accepted_arg in zip(
|
|
915
|
+
for provided_arg, accepted_arg in zip(
|
|
916
|
+
provided_args, accepted_args, strict=False
|
|
917
|
+
)
|
|
894
918
|
if accepted_arg is not Any
|
|
895
919
|
)
|