From 8466a33c920d603015f464ad816eae18a37122e7 Mon Sep 17 00:00:00 2001 From: stefefn Date: Thu, 14 May 2026 00:28:13 +0200 Subject: [PATCH] fix: support Python 3.14 annotations in assign_attr_with_json Python 3.14 (PEP 649) no longer populates cls.__dict__["__annotations__"] for lazily-evaluated annotations, causing a KeyError when loading drafts. Replace the manual __dict__ lookup with inspect.get_annotations(cls), which works correctly across Python 3.10+. --- pyJianYingDraft/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyJianYingDraft/util.py b/pyJianYingDraft/util.py index 007c132..7666d98 100644 --- a/pyJianYingDraft/util.py +++ b/pyJianYingDraft/util.py @@ -35,8 +35,7 @@ def assign_attr_with_json(obj: object, attrs: List[str], json_data: Dict[str, An """ type_hints: Dict[str, Type] = {} for cls in obj.__class__.__mro__: - if '__annotations__' in cls.__dict__: - type_hints.update(cls.__annotations__) + type_hints.update(inspect.get_annotations(cls)) for attr in attrs: if hasattr(type_hints[attr], 'import_json'):