Avoid deprecated Pydantic v2 field introspection

Merged
LA
4d ago
+118-8

Reading a Pydantic v2 model field currently goes through fields, emitting the same deprecation warning several times during page compilation. The type helpers now prefer model_fields when it contains field metadata and fall back to fields for v1 models, including models with an unrelated method named model_fields. Regression tests cover inherited fields, optional and list annotations, missing fields, empty models and property precedence. Fixes #7561.

The full Python 3.14 unit suite passes with 12,026 tests and 80.03% coverage. Running it without the optional database dependencies also passes with 10,261 tests. The related type tests pass on Python 3.12 with both Pydantic versions. Ruff, Pyright and the reflex-base source and wheel builds pass.