`rx.Model` event arguments emit `PydanticDeprecatedSince20` once per payload key
维护者通常 2 天内回复
评估
调研方向
从packages/reflex-base/src/reflex_base/event/processor/base_state_processor.py:141开始并阅读_transform_event_arg,然后运行 issue 中的复现步骤以确认警告。过滤 payload 时使用一次模型字段键。完成的标准是同一转换不再发出PydanticDeprecatedSince20警告。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
An event handler argument can have an rx.Model type hint. When the payload is a dict, _transform_event_arg removes the keys that are not model fields. It checks each key with hinted_args.__fields__. Pydantic v2 deprecates __fields__, so each key emits one PydanticDeprecatedSince20 warning, on every event.
Code: packages/reflex-base/src/reflex_base/event/processor/base_state_processor.py:141
if key in hinted_args.__fields__
To Reproduce
import warnings
import reflex as rx
from reflex_base.event.processor.base_state_processor import _transform_event_arg
class Tbl(rx.Model, table=True):
name: str
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
_transform_event_arg({"name": "a", "extra": 1, "other": 2}, Tbl)
for w in caught:
print(w.category.__name__, w.filename.split("src/")[-1], w.lineno)
Output on main (7f89e48c3):
PydanticDeprecatedSince20 reflex_base/event/processor/base_state_processor.py 141
PydanticDeprecatedSince20 reflex_base/event/processor/base_state_processor.py 141
PydanticDeprecatedSince20 reflex_base/event/processor/base_state_processor.py 141
Expected behavior
No deprecation warning. rx.Model is a SQLModel, which is Pydantic v2, so hinted_args.model_fields gives the same keys. Read it once, not once per key.
rx.Model is deprecated, so this only matters until it is removed. The fix is one line.
Specifics
- Python 3.14.6, pydantic 2.13.5, reflex
main(7f89e48c3) - Related: #7561 and #7592 fix the same warning in
reflex_base/utils/types.py.
- 主要语言
- Python
- 星标
- 29k
- 派生
- 1.8k
- 平均合并
- 3 天 7 小时
- 30 天内合并 PR
- 181
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
reflex-dev/reflex 的其他 Issue
-
Add a `SetVar` backed by the JS `Set` object可能已有人在做 @Huzi-06 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
reflex-dev/reflex#7623 · 2 条评论 ·
维护者通常 2 天内回复
-
`get_field_type` and `get_attribute_access_type` read `__fields__` and emit `PydanticDeprecatedSince20` on each field access可能已有人在做 @LaoChouPro 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
reflex-dev/reflex#7561 · 1 条评论 ·
维护者通常 2 天内回复
-
`reflex run --json` ignores SIGINT sent to its pid; under supervisord stopsignal=INT the app is orphaned and blocks the restart可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
reflex-dev/reflex#7509 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
reflex-dev/reflex#7260 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#7148 · 1 条评论 ·
维护者通常 2 天内回复
查看 reflex-dev/reflex 的全部 Issue
相似的 Issue
-
Python Volcengine provider returns failures instead of raising them可能已有人在做 @Ricardo-M-L 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
agent-infra/sandbox#248 ·
-
Textractor leaves empty temporary files when remote retrieval fails可能已有人在做 @HuaTNA 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
test(bm_generation): pin the learning parameters and CPU sync shortcut可能已有人在做 @iloveeyjafjalla 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
qboson/kaiwu-pytorch-plugin#1341 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
elder-plinius/V3R1T4S#625 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复