Repository navigation
fix: accept bound methods as rx.foreach render functions - #7957
benedikt-bartscher wants to merge 4 commits into
Conversation
[Medium impact] The change reaches the shared `rx.foreach` callback behavior. Raise the minimum version of Findings
Summary
Reviews (2) · Last reviewed commit: "Merge commit 'a96668a385f626ce80b5d2b5e0..." · Reviewed by Greptile |
Merging this PR will degrade performance by 5.6%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
…ach-bound-method-render-fn # Conflicts: # packages/reflex-base/src/reflex_base/components/tags/iter_tag.py
|
|
||
| from reflex_base.components.component import Component, field | ||
| from reflex_base.components.tags import IterTag | ||
| from reflex_base.components.tags.iter_tag import _render_fn_params |
There was a problem hiding this comment.
Allowed installations fail to import
foreach.py now imports _render_fn_params, but reflex-components-core still allows reflex-base >= 0.11.0. That released version lacks the helper, so an allowed installation fails with ImportError when importing foreach.py.
The repository guide requires raising a sibling dependency's minimum version when using its unreleased code. Raise the reflex-base minimum in packages/reflex-components-core/pyproject.toml to 0.11.1.dev0.
Context Used: CLAUDE.md (source)
rx.foreachrejects a bound method as its render function:Foreach._rendercounts the render function's parameters withinspect.signature, which leaves out a bound method'scls/self.IterTag.render_componentcounted them again withinspect.getfullargspec(...).args, which includes it. So a one-argument classmethod was called with the index as well, and a two-argument classmethod or instance method failed the "must take 2 arguments" check. Both now count the render function's parameters with the same helper,_render_fn_params: only positional parameters take the item and the index, so keyword-only parameters and**kwargsnever receive the index. A render function without positional parameters, likerx.text(Text.create(cls, *children, **props)), gets the item only, as it did before.The workaround is a lambda (
lambda item: Page.row(item)), which ruff'sPLW0108(unnecessary-lambda) then flags.