reflex/tests/components
benedikt-bartscher e42d4ed9ef
[REF-3009] type transforming serializers (#3227)
* wip type transforming serializers

* old python sucks

* typing fixups

* Expose the `to` parameter on `rx.serializer` for type conversion

Serializers can also return a tuple of `(serialized_value, type)`, if both ways
are specified, then the returned value MUST match the `to` parameter.

When initializing a new rx.Var, if `_var_is_string` is not specified and the serializer returns a `str` type, then mark `_var_is_string=True` to indicate that the Var should be treated like a string literal.

Include datetime, color, types, and paths as "serializing to str" type.

Avoid other changes at this point to reduce fallout from this change:

  Notably, the `serialize_str` function does NOT cast to `str`, which
  would cause existing code to treat all Var initialized with a str as a
  str literal even though this was NOT the default before.

Update test cases to accomodate these changes.

* Raise deprecation warning for rx.Var.create with string literal

In the future, we will treat strings as string literals in the JS code. To get
a Var that is not treated like a string, pass _var_is_string=False.

This will allow our serializers to automatically identify cast string literals
with less special cases (and the special cases need to be explicitly
identified).

* Add test case for mismatched serialized types

* fix old python

* Remove serializer returning a tuple feature

Simplify the logic; instead of making a wrapper function that returns
a tuple, just save the type conversions in a separate global.

* Reset the LRU cache when adding new serializers

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-06-07 09:50:10 -07:00
..
base generate pyi files when building/publishing 3rd party component (#2945) 2024-03-29 09:54:21 -07:00
core [REF-3009] type transforming serializers (#3227) 2024-06-07 09:50:10 -07:00
datadisplay Top-level namespace tweaks (#2523) 2024-02-05 11:14:02 -08:00
el Lendemor/improve coverage (#2988) 2024-04-04 14:31:43 +02:00
forms [REF-2821]Improve Dynamic Imports (#3345) 2024-05-31 16:43:10 +00:00
graphing Layout property not pushed through on rx.plotly (#3394) 2024-05-31 11:48:43 -07:00
layout generate pyi files when building/publishing 3rd party component (#2945) 2024-03-29 09:54:21 -07:00
lucide add_style api (#3202) 2024-05-06 16:59:11 -07:00
media Use rx.el.img as rx.image (#2558) 2024-02-08 14:44:53 -08:00
radix add_style api (#3202) 2024-05-06 16:59:11 -07:00
typography Remove deprecations for 0.5.0 (#3222) 2024-05-07 08:55:42 -07:00
__init__.py Add basic unit tests (#7) 2022-11-20 14:34:25 -08:00
test_component_future_annotations.py [REF-2272] Support declaring EventHandlers directly in component (#2952) 2024-03-29 06:26:07 -07:00
test_component_state.py [REF-2265] ComponentState: scaffold for copying State per Component instance (#2923) 2024-03-29 09:22:25 -07:00
test_component.py [REF-2821]Improve Dynamic Imports (#3345) 2024-05-31 16:43:10 +00:00
test_tag.py fixed issue with hypens (#2450) 2024-01-26 14:14:46 -08:00