PrefectHQ
prefect
BlogDocsChangelog

Fix forward reference resolution in `ValidatedFunction`

#19289Merged
Comparing
fix-19288
(
1810a4e
) with
main
(
7fcfb7e
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s
bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
455.6 µs457.1 µs

Ignored

bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-12%
5.5 ms6.3 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
107.5 ms107.7 ms
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-2%
165.8 ms168.9 ms
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-4%
161.9 ms169 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-13%
5.5 ms6.3 ms
bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
1 s1 s

Commits

Click on a commit to change the comparison range
Base
main
7fcfb7e
-0.07%
Fix forward reference resolution in ValidatedFunction Closes #19288 This PR fixes an issue where Flow.validate_parameters() fails when using Pydantic models as parameters with `from __future__ import annotations`. The problem occurred because the dynamically created validation model didn't have access to the original function's namespace to resolve forward references. The fix adds model_rebuild() with the function's global namespace, allowing proper resolution of forward references to Pydantic models. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
99d0333
3 days ago
by desertaxle
+0.33%
Optimize model_rebuild to only run when forward refs detected This commit adds a performance optimization to avoid calling model_rebuild() when there are no forward references in the function signature. The optimization: - Detects string annotations during field building - Only calls model_rebuild() if forward references are found - Avoids unnecessary overhead for functions without forward refs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
9427aa2
3 days ago
by desertaxle
-0.4%
Remove useless test
1810a4e
3 days ago
by desertaxle
© 2025 CodSpeed Technology
Home Terms Privacy Docs