- After debugging, I found that the issue was caused by the following import:
from _future_ import annotations
When I removed this import, the issue was resolved.
The error occurs because `from _future_ import annotations` enables postponed evaluation of type hints, which can interfere with Pydantic's handling of forward references in certain cases.
To fix this issue:
- Remove the from _future_ import annotations import if it's not necessary.