Operations on a list[T] | None var throw when the value is None
维护者通常 1 天内回复
评估
调研方向
Issue 提到了 ArrayVar 及其数组操作,并以 SetVar.to_array() 中对可选集合的处理作为参考。阅读 #7800 的更改,追踪可选列表的 contains 和 length 如何编译;使用提供的示例重现故障。当 None 被渲染为空列表,使得 contains 为 false、length 为 0,且 prerender 成功时,即告完成。
由索引模型根据 Issue 内容生成。
描述
Operations on a list[T] | None var that holds None throw on the frontend. #7800 fixes the same defect for set[T] | None (SetVar). Optional lists still have it.
Repro
import reflex as rx
class State(rx.State):
items: rx.Field[list[str] | None] = rx.field(None)
def index():
return rx.vstack(
rx.text(State.items.contains("x")),
rx.text(State.items.length()),
)
app = rx.App()
app.add_page(index)
Result
The page does not render:
TypeError: Cannot read properties of null (reading 'includes')
length() fails the same way (null.length). The prod prerender fails for the same reason.
Expected
A None list acts as an empty list: contains is false and length is 0. This is the rule that #7800 uses for optional sets.
Suggested fix
Give an optional ArrayVar the same null-safe view that #7800 adds to SetVar.to_array(), which compiles to (x ?? []). Use that view in the array operations.
- 主要语言
- Python
- 星标
- 29k
- 派生
- 1.8k
- 平均合并
- 2 天 22 小时
- 30 天内合并 PR
- 143
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
reflex-dev/reflex 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
reflex-dev/reflex#7825 · 1 条评论 ·
维护者通常 1 天内回复
-
PropsBase nested serialization applies parent include/exclude filters to child fields可能已有人在做 @harsh21234i 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#7787 · 1 条评论 ·
维护者通常 1 天内回复
-
OTel: add trace_flags to JSON log records so unsampled trace ids are recognizable可能已有人在做 @ShaanGS 于 7 天前认领。 未关闭enhancement
难度 2/5 1-3 小时 新手友好度 82/100
reflex-dev/reflex#7729 · 1 条评论 ·
维护者通常 1 天内回复
-
0.9.12 changelog follow-ups: the #7132 "_get_was_touched" entry describes unreachable behaviour, #7115's hasattr/getattr change is undocumented, #7131's wording可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
reflex-dev/reflex#7260 · 2 条评论 ·
维护者通常 1 天内回复
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the default可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#6823 · 1 条评论 ·
维护者通常 1 天内回复
查看 reflex-dev/reflex 的全部 Issue
相似的 Issue
-
[Bug]: graphify query loads every language extractor just for _file_stem (about 34 ms per call)可能已有人在做 @rohit-jsfreaky 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Graphify-Labs/graphify#5160 · 1 条评论 ·
维护者通常 2 天内回复
-
Variable declared without a value suppresses ${VAR:-default} expansion可能已有人在做 @Omarinho12345 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
theskumar/python-dotenv#750 ·
维护者通常 12 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 78/100
UKGovernmentBEIS/control-arena#947 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
jasonacox/Powerwall-Dashboard#897 · 1 条评论 ·
维护者通常 1 天内回复