`get_field_type` and `get_attribute_access_type` read `__fields__` and emit `PydanticDeprecatedSince20` on each field access
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
已弃用的读取位于 reflex_base/utils/types.py:get_field_type 中第 589-594 行以及 get_attribute_access_type 中第 710 行的 __fields__ 访问。首先运行 issue 中的复现脚本,并检查警告数量。当脚本报告 0 条 PydanticDeprecatedSince20 警告,且字段类型的解析结果与之前一致时,即完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Reflex reads cls.__fields__ when it resolves the type of a field on a Pydantic v2 model. Pydantic v2 deprecates __fields__, so each read emits PydanticDeprecatedSince20. One field access on a Var emits 7 warnings.
The reads are in reflex_base/utils/types.py (reflex-base 0.9.12):
get_attribute_access_type, line 710: 2 reads.get_field_type, lines 589 to 594: 5 reads.
The same code is in 0.9.13 and 0.10.0. In 0.10.0, the lines are 580 to 585 and 701.
To Reproduce
import warnings
import pydantic
import reflex as rx
class Item(pydantic.BaseModel):
name: str
size: int
class ItemState(rx.State):
items: list[Item] = []
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
rx.foreach(ItemState.items, lambda item: rx.text(item.name, " ", item.size))
deprecations = [record for record in caught if issubclass(record.category, pydantic.warnings.PydanticDeprecatedSince20)]
print(f"{len(deprecations)} PydanticDeprecatedSince20 warnings")
for warning in deprecations:
print(f" {warning.filename.split('site-packages/')[-1]}:{warning.lineno}")
Output with Python 3.14.6, reflex 0.9.12, reflex-base 0.9.12 and pydantic 2.14.0:
14 PydanticDeprecatedSince20 warnings
reflex_base/utils/types.py:710
reflex_base/utils/types.py:710
reflex_base/utils/types.py:589
reflex_base/utils/types.py:590
reflex_base/utils/types.py:591
reflex_base/utils/types.py:592
reflex_base/utils/types.py:594
(the same 7 lines again for the second field)
The script accesses 2 fields, and each access emits 7 warnings. In our app, one page compile does 176 field accesses and emits 1,232 warnings.
Expected behavior
Reflex resolves field types on Pydantic v2 models without deprecation warnings.
Specifics (please complete the following information):
- Python Version: 3.14.6
- Reflex Version: 0.9.12
- OS: macOS 26.6.2 (build 25G83), on Apple Silicon (arm64)
Additional context
Related: #6241, #6135.
- 主要语言
- Python
- 星标
- 28.9k
- 派生
- 1.8k
- 平均合并
- 2 天 14 小时
- 30 天内合并 PR
- 211
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
reflex-dev/reflex 的其他 Issue
-
`reflex run --json` ignores SIGINT sent to its pid; under supervisord stopsignal=INT the app is orphaned and blocks the restart可能已有人在做 @harsh21234i 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
reflex-dev/reflex#7509 · 1 条评论 ·
维护者通常 1 天内回复
-
npm: source-only hot reloads still reinstall packages because the rendered package.json has `devDependencies: {}` while the on-disk one has no key (residual of #7235)可能已有人在做 @harsh21234i 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
reflex-dev/reflex#7480 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
reflex-dev/reflex#7260 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#7148 · 1 条评论 ·
维护者通常 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
-
customer-reported question
难度 2/5 1-3 小时 新手友好度 62/100
Azure/azure-sdk-for-python#49548 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
btclib-org/btclib-wallet#409 ·
维护者通常 1 天内回复
-
Phase 2 PSA Capability & Career Profile
难度 2/5 1-3 小时 新手友好度 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 78/100
fastmachinelearning/hls4ml#1582 ·
维护者通常 3 天内回复
-
Sort models未关闭enhancement good first issue
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复