From b0d87e3508769a631e66a6e9f503dab2f1b5c0b7 Mon Sep 17 00:00:00 2001 From: Danny Cooper Date: Fri, 17 Nov 2023 15:47:00 +0000 Subject: [PATCH] Use _get_annotations rather than branching on class dict entry --- src/attr/_make.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/attr/_make.py b/src/attr/_make.py index d96113bee..55ab31fab 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -920,11 +920,11 @@ def _create_slots_class(self): # Clear out function from class to avoid clashing. del cd[name] - if "__annotations__" in cd: - for name, func in cached_properties.items(): - annotation = inspect.signature(func).return_annotation - if annotation is not inspect.Parameter.empty: - cd["__annotations__"][name] = annotation + class_annotations = _get_annotations(self._cls) + for name, func in cached_properties.items(): + annotation = inspect.signature(func).return_annotation + if annotation is not inspect.Parameter.empty: + class_annotations[name] = annotation original_getattr = cd.get("__getattr__") if original_getattr is not None: