Commit Graph

2239 Commits

Author SHA1 Message Date
Khaleel Al-Adhami
0ad0a84ee1
fix recursive UI (#4599)
* fix recursive UI

* get it right pyright

* dang it darglint
2025-01-07 15:11:38 -08:00
Khaleel Al-Adhami
880975ae94
improve client state (#4597)
* improve client state

* no comma

* update python for unit tests

* overwrite it for windows

* bump other python versions
2025-01-07 14:41:03 -08:00
Masen Furer
93245ef143
[ENG-4255] Code blocks lead to redefined const in web page (#4598)
Instead of potentially defining `_LANGUAGE` constant twice in a component,
simply pass the language prop directly to the hook generator function.

If no language is passed, then it defaults to `_LANGUAGE`, which continues to
work for markdown component_map use case.
2025-01-07 13:20:25 -08:00
Masen Furer
5f169bc884
test_lifespan: stop periodic events (#4600)
avoid lingering events after getting the information we came for
2025-01-07 13:20:10 -08:00
Masen Furer
08d9fbf9bc
unbreak link _hover (#4537)
* unbreak link _hover

* add a test to catch the error

* change tmp path for harness

* add () to fixture

* add spacer to avoid initial hover

* only install chromium browser for faster ci

---------

Co-authored-by: Lendemor <thomas.brandeho@gmail.com>
2025-01-07 10:35:36 -08:00
Masen Furer
72d7616726
Enable automatic retry on redis errors (#4595)
* Enable automatic retry on redis errors

ExponentialBackoff 3x retry for BusyLoadingError, ConnectionError, and TimeoutError

* retry on any redis error

* Use default single-retry for any RedisError

Using the default Retry means that async and sync clients get the appropriate type of Retry
2025-01-07 10:24:43 -08:00
Masen Furer
eae15e3a83
poetry 2.0.0 compatibility (#4593)
Remove `packages` key, since this project uses the "default" package layout, so
this key isn't needed.
2025-01-06 14:35:45 -08:00
Thomas Brandého
9fafb6d526
use position in vardata to mark internal hooks (#4549)
* use position in vardata to mark internal hooks

* update all render to use position

* use macros for rendering

* reduce number of iterations over hooks during rendering

* cleanup code and add typing

* add __future__

* use new macros to render component maps in markdown

* remove calls to _get_all_hooks_internal

* fix typo

* forgot to replace this

* unnecessary expand in utils.py
2025-01-06 13:06:56 -08:00
Masen Furer
59b3aaca42
Add deprecation message for non-cached var (#4591)
DeprecationWarning: Default non-cached rx.var has been deprecated in version
0.6.8 the default value will be `@rx.var(cache=True)` in a future release. To
retain uncached var, explicitly pass `@rx.var(cache=False)`. It will be
completely removed in 0.7.0
2025-01-06 11:17:03 -08:00
Kanva Bhatia
ab4e05be34
fixes #4578 - correct the way dim_props created (#4587) 2025-01-05 14:53:39 -08:00
Masen Furer
dcdcbfd833
[ENG-2157] [Refix] Allow rx.download to resolve rx.get_upload_url (#4470)
* [ENG-2157] [Refix] Allow `rx.download` to resolve `rx.get_upload_url`

Update the special case in a way that works with the new Var system and its
unstoppable determination to concatenate strings instead of using template
string

This has been broken since 0.6.0, so a regression test was added to avoid
future inadvertant breakage.

Fix #2812 (again)

* use safer indirect eval
2025-01-03 16:56:29 -08:00
Masen Furer
438b31f270
[ENG-4005] Proxy backend requests on '/' to the frontend (#3300)
* Proxy backend requests on '/' to the frontend

If the optional extra `proxy` is installed, then the backend can handle all
requests by proxy unrecognized routes to the frontend nextjs server.

* Update lock file

* pre-commit fu

* AppHarness: set config frontend_port and backend_port

* integration: frontend port and backend port should return the same content

with proxying enabled by default in dev mode, both frontend and backend ports
on / should return the same content.

* Retry up to 100 times when proxying to frontend

* Reduce retry attempts to 25

Fix log level passing to subprocess

* scripts/wait_for_listening_port: primarily check HTTP responses

if the port is up or not, we don't really care... the HTTP request needs to
work and not return errors

* aiohttp is an optional dep

* adapt integration.sh for --backend-only (counter integration test)

* woops

* windows WTF?

* scratching my head 🎄

* double WTF windows

* Fix remaining integration tests
2025-01-03 15:50:38 -08:00
Masen Furer
316a0c9bde
Do not allow call_function callback argument to be added afterwards (#4552)
The default behavior for EventSpec is to treat the spec as a partial, wherein
if additional unfilled arguments are available, and the event trigger wants to
pass additional arguments, they will be applied positionally.

However, it never makes sense to fill in `callback` with an event trigger arg.
Therefore, if the callback is not provided initially, set it to None explicitly
so that some invalid value cannot be added later.
2025-01-03 15:50:01 -08:00
Masen Furer
8477a1aba0
BaseState.get_var_value helper to get a value from a Var (#4553)
* BaseState.get_var_value helper to get a value from a Var

When given a state Var or a LiteralVar, retrieve the actual value associated
with the Var.

For state Vars, the returned value is directly tied to the associated state and
can be modified.

Modifying LiteralVar values or ComputedVar values will have no useful effect.

* Use Var[VAR_TYPE] annotation to take advantage of generics

This requires rx.Field to pass typing where used.

* Add case where get_var_value gets something that's not a var
2025-01-03 15:49:46 -08:00
Masen Furer
41cb2d8cff
[ENG-4083] Track internal changes in dataclass instances (#4558)
* [ENG-4083] Track internal changes in dataclass instances

Create a dynamic subclass of MutableProxy with `__dataclass_fields__` set
according to the dataclass being wrapped.

* support dataclasses.asdict on MutableProxy instances
2025-01-03 15:49:28 -08:00
Simon Young
4b89b8260b
HOS-400: adding support for config (#4540)
* HOS-400: adding support for config

* ruff

---------

Co-authored-by: simon <simon@reflex.dev>
2025-01-03 15:15:13 -08:00
benedikt-bartscher
879dcbd1bf
improve dynamic route vars, no need to compute deps (#4551) 2025-01-03 13:00:48 -08:00
celsius narhwal
0d9b2c75e4
Upgrade lucide-react to version 0.469.0 (#4571) 2025-01-03 12:59:05 -08:00
JonZeolla
72a60f074b
chore: update sonner (toast) (#4572) 2025-01-03 12:55:51 -08:00
Thomas Brandého
53f09756b6
autodetect print/breakpoints (#4581)
* catch stray breakpoints and prints

* autodetect debug prints and breakpoints in main code

* readd hacky print in pyi_generator?
2025-01-03 12:51:02 -08:00
Ryan
97fb157b25
Add endswith method to String class (#4577)
Co-authored-by: ryan <>
2025-01-03 12:50:04 -08:00
Masen Furer
12eaf08c88
Add expire_on_commit=False for async sessions (#4582) 2025-01-02 14:15:59 -08:00
Masen Furer
41ed9f0514
Move _create_event_chain to EventChain.create (#4557)
The ability to convert `EventType` arguments into `EventChain` is crucial for
wrapping JS libraries that need to pass event handlers via hooks or
other non-component centric interfaces.

Improve typing such that wrapped components accepting `EventType` arguments can
be directly converted to `EventChain` / `EventChainVar` to be rendered as JS
code.
2025-01-02 14:15:38 -08:00
Thomas Brandého
848b87070c
fix health check and skip not needed tasks (#4563) 2024-12-20 17:08:10 -08:00
Thomas Brandého
a2ec1bc1d8
add codespell to pre-commit (#4559) 2024-12-20 17:04:39 -08:00
benedikt-bartscher
c310c020bb
Minor performance improvements for state getattribute and setattr (#4543) 2024-12-20 16:27:07 -08:00
Masen Furer
28568fd12f
Suppress exceptions from telemetry send (#4564) 2024-12-19 16:20:09 -08:00
Masen Furer
d8e988105f
pyproject.toml: bump to 0.6.8dev1 for further development (#4539) 2024-12-17 19:52:37 +01:00
Masen Furer
f71e6f9559
Revert "only mark backend vars as dirty if they have changed (#4494)" (#4547)
This reverts commit 3d89d74bdc.
2024-12-16 12:21:32 -08:00
Thomas Brandého
d7956c19d3
enable PERF rules (#4469)
* enable PERF rules

* fix scripts folder

* Update reflex/compiler/utils.py

Co-authored-by: Masen Furer <m_github@0x26.net>

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-13 14:49:37 -08:00
Thomas Brandého
61cb72596e
enable PTH rule (#4476)
* enable PTH rule

* fix import in test_call_script

* fix units tests

* reorder ruff rules

* Update reflex/utils/build.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* format pyproject.toml

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-13 14:06:26 -08:00
Thomas Brandého
1444421766
add deps and position field in VarData (#4518)
* fix memoized event trigger order

* allow to declare deps in event signature for memoized event triggers

* clean up the code to pass tests

* handle position of hooks

* clean up code

* revert test changes

* add future annotations

* remove non-necessary stuff

* reuse data_callback name if already set during first call to add_hooks

* remove HookVar and use Var with VarData instead

* remove test change

* readd removed line

* fix order of stmt for cleaner code

* fix typing

* something broke during the merge I guess

* remove hack and pass proper const for position

* oops, bad syntax in jinja

* use "hook_position" instead of "hook_positions"

match the name of the enum

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-13 13:28:55 -08:00
Thomas Brandého
76ce112002
add datetime var comparison operations (#4406)
* add datetime var operations

* add future annotations

* add LiteralDatetimeVar

* remove methods that don't apply

* fix serialization

* add unit and integrations test

* oops, forgot to commit that important change
2024-12-13 12:41:29 -08:00
benedikt-bartscher
682bca7f9a
improve StateManagerRedis error message (#4444) 2024-12-13 12:40:38 -08:00
Thomas Brandého
ff510cacc5
enable C4 rule (#4536) 2024-12-13 12:37:34 -08:00
Joodith
ec89702137
Include step attribute in input (#4073)
* Include step attribute in input

* Remove `step` prop from TextField

it is inherited from Input, and does not need to be redefined

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-13 11:35:35 -08:00
Elijah Ahianyo
206de4df7a
Unify is_external prop in rx.redirect and rx.link (#4389)
* Unify `is_external` prop in `rx.redirect` and `rx.link`

* default external to `None`

* address PR comment

* use a one-liner

* reorder args for api stability

Co-authored-by: Masen Furer <m_github@0x26.net>

* reorder doc args

* external arg as deprecated in the docs

* Update reflex/event.py

Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>

* Fixup typing_extensions import and ruff

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
2024-12-13 11:27:51 -08:00
Masen Furer
f4aea1b3ab
[ENG-3583] Respect cors_allowed_origins for backend HTTP requests (#4533) 2024-12-13 09:31:27 -08:00
Vy Nguyen
7208540855
Wrap Checkbox component in Context Menu (partial fix for #4262) (#4479)
* Add ContextMenuCheckBoxItem component

* Remove toggle_state method

* Import Checkbox and implement ContextMenuCheckbox class

* Change parameter for create function

* Reformat code and import block

* Removed unused vars

* Format file

* Remove create method

* Reformat code

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Reformat code

* Add automatically modified pyi file

* Update context_menu.pyi file

---------

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
2024-12-13 01:50:01 +01:00
Elijah Ahianyo
7ca50c62e2
[ENG-4153]Use empty string for None values in rx.input and rx.el.input (#4521)
* Use empty string for None values in `rx.input` and `rx.el.input`

* fix tests

* fix pyi scripts

* use nullish coalescing operator

* fix unit tests

* use ternary operator so old browsers and dynamic components tests pass

* address comment on doing this only for optionals

* Fix tests

* pyright!

* fix comments
2024-12-12 15:24:15 -08:00
Masen Furer
d5d41a0d9e
raise_console_error during integration tests (#4535) 2024-12-12 14:28:30 -08:00
Masen Furer
60a5b7bc7a
[ENG-4194] TypeError: Cannot create property 'token' on string (#4534) 2024-12-12 14:28:17 -08:00
Elijah Ahianyo
c387f517b6
[ENG-4100]Throw warnings when Redis lock is held for more than the allowed threshold (#4522)
* Throw warnings when Redis lock is held for more than the allowed threshold

* initial tests

* fix tests and address comments

* fix tests fr, and use pydantic validators

* darglint fix

* increase lock expiration in tests to 2500

* remove print statement

---------

Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
2024-12-12 11:36:31 -08:00
Masen Furer
2d9849e00a
Fix upload cancellation (#4527)
* Improve assertions in test_cancel_upload

* Fix upload cancellation by using `refs` instead of `upload_controllers`
2024-12-12 10:15:19 -08:00
Masen Furer
adfda8adfd
[ENG-4165] Consider default and default_factory for state vars (#4510)
* [ENG-4165] Consider default and default_factory for state vars

When determining whether a state var should be marked as optional, check that
it is missing both default and default_factory and is not required.

Fix #4471

* add test for default factory with rx.foreach (#4515)

---------

Co-authored-by: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com>
2024-12-12 10:10:44 -08:00
benedikt-bartscher
1b6f539657
simplify redis code, less redis calls (#4456)
* simplify redis code, less redis calls

* cleanup

* properly ignore non-lock events from redis pubsub, keep timeout
2024-12-12 05:56:42 -08:00
Masen Furer
a2f14e7713
Avoid double JSON encode/decode for socket.io (#4449)
* Avoid double JSON encode/decode for socket.io

socket.io (python and js) already has a built in mechanism for JSON encoding
and decoding messages over the websocket. To use it, we pass a custom `json`
namespace which uses `format.json_dumps` (leveraging reflex serializers) to encode the
messages. This avoids sending a JSON-encoded string of JSON over the wire, and
reduces the number of serialization/deserialization passes over the message
data.

The side benefit is that debugging websocket messages in browser tools displays
the parsed JSON hierarchy and is much easier to work with.

* JSON5.parse in on_upload_progress handler responses
2024-12-12 05:47:23 -08:00
Masen Furer
053cbe7558
bump CI runners to macos-latest (#4526)
* use `macos-latest` runner

macos-12 is deprecated and the jobs don't start anymore, so see if we can run
fine on latest.

* unit_tests.yml: use python versions with arm64 builds
2024-12-12 04:17:28 -08:00
benedikt-bartscher
ea90a3ebfa
minor pickle improvement (#4499) 2024-12-12 02:07:59 -08:00
Thomas Brandého
5e026e4b27
Support python 3.13 (#4206)
* bump playwright and run tests with 3.13

* test with psycopg3

* typo

* update everything for psycopg 3.
2024-12-12 00:10:51 -08:00