Skip to content

Commit 537c10e

Browse files
ESultanikclaude
andcommitted
Fix Python 3.14 compatibility (PEP 649)
Python 3.14 implements PEP 649 (Deferred Evaluation of Annotations), which changes how annotations are stored. Annotations are no longer in clsdict["__annotations__"] during metaclass __init__, but are available on cls.__annotations__ after class creation. Update StructMeta to use cls.__annotations__ instead, which works across all Python versions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent abaef67 commit 537c10e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

polyfile/structs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ class StructMeta(ABCMeta):
229229

230230
def __init__(cls, name, bases, clsdict):
231231
cls.fields = OrderedDict()
232-
if "__annotations__" in clsdict:
233-
for field_name, field_type in clsdict["__annotations__"].items():
232+
if hasattr(cls, "__annotations__"):
233+
for field_name, field_type in cls.__annotations__.items():
234234
if isinstance(field_type, type) and issubclass(field_type, Field):
235235
if field_name in cls.fields:
236236
raise TypeError(f"Invalid redeclaration of struct field {field_name} in {cls.__name__}")

0 commit comments

Comments
 (0)