`get_field_type` and `get_attribute_access_type` read `__fields__` and emit `PydanticDeprecatedSince20` on each field access
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The deprecated reads are in reflex_base/utils/types.py: the __fields__ accesses at lines 589-594 in get_field_type and line 710 in get_attribute_access_type. Start by running the reproduction script in the issue and checking the warning count. Done means the script reports 0 PydanticDeprecatedSince20 warnings and the field types resolve as before.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 28.9k
- Forks
- 1.8k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 211
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reflex-dev/reflex
-
`reflex run --json` ignores SIGINT sent to its pid; under supervisord stopsignal=INT the app is orphaned and blocks the restartPossibly taken @harsh21234i claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
reflex-dev/reflex#7509 · 1 comment ·
Maintainers usually reply within 1 day
-
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)Possibly taken @harsh21234i claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
reflex-dev/reflex#7480 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
reflex-dev/reflex#7260 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
reflex-dev/reflex#7148 · 1 comment ·
Maintainers usually reply within 1 day
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the defaultMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
reflex-dev/reflex#6823 · 1 comment ·
Maintainers usually reply within 1 day
All issues in reflex-dev/reflex
Similar issues
-
Agentic
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Imbad0202/academic-research-skills#979 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
prometheus-community/ansible#906 · 2 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Deltares/imod-python#1940 ·
Maintainers usually reply within 1 day