Commits
Click on a commit to change the comparison rangefix: defer forward reference resolution in ValidatedFunction
closes #19447
When using `from __future__ import annotations`, the `@flow` decorator
was failing if a forward-referenced Pydantic model was defined after
the function using it.
The issue occurred because ValidatedFunction tried to resolve forward
references at decoration time by calling `model_rebuild()`, but the
referenced types didn't exist in the function's `__globals__` yet.
This fix:
- Tracks deferred rebuilds with `_needs_rebuild` flag to avoid performance overhead
- Only calls `model_rebuild()` once during first validation if needed
- Catches NameError/AttributeError during initial model_rebuild attempt
- Extended test coverage to ensure no rebuilds happen when not needed
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>