Skip to content

Conversation

@w0r1dhe110
Copy link

Description:
Update annotation access to maintain compatibility with Python 3.14's deferred annotation evaluation (PEP 649 & PEP 749).

In Python 3.14, annotations are no longer eagerly evaluated and stored directly in annotations. Instead, they're deferred and accessed through special mechanisms. This change caused our previous direct dictionary access to fail with a KeyError.

The fix replaces direct dict["annotations"] access with getattr(..., "annotations", {}) which safely handles both:

Pre-3.14 versions where annotations are stored directly in annotations Python 3.14+ where annotations use deferred evaluation This ensures consistent behavior across Python versions while leveraging the new annotation system's benefits in 3.14+.

Description:
Update annotation access to maintain compatibility with Python 3.14's deferred annotation evaluation (PEP 649 & PEP 749).

In Python 3.14, annotations are no longer eagerly evaluated and stored directly in __annotations__. Instead, they're deferred and accessed through special mechanisms. This change caused our previous direct dictionary access to fail with a KeyError.

The fix replaces direct __dict__["__annotations__"] access with getattr(..., "__annotations__", {}) which safely handles both:

Pre-3.14 versions where annotations are stored directly in __annotations__
Python 3.14+ where annotations use deferred evaluation
This ensures consistent behavior across Python versions while leveraging the new annotation system's benefits in 3.14+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant