Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`rx.Model` event arguments emit `PydanticDeprecatedSince20` once per payload key

未关闭 适合新手
#7,634 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@fixfon 已经在做这个了。

开始于 2026年10月22日。

  • #7636 来自 @fixfon —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend, testing

调研方向

从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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

reflex-dev/reflex 的其他 Issue

查看 reflex-dev/reflex 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。