Skip to content

Commit 9efd912

Browse files
committed
Support string return annotation
1 parent aca32a5 commit 9efd912

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/attr/_make.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ def _make_cached_property_uncached(original_cached_property_func, cls):
586586
annotation = inspect.signature(
587587
original_cached_property_func
588588
).return_annotation
589-
assert not isinstance(annotation, str)
590589
if annotation is inspect.Parameter.empty:
591590
defline = f"def {name}(self):"
592591
elif isinstance(

tests/test_slots.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,15 @@ def f(self) -> functools.partial:
780780
return_annotation = eval(return_annotation)
781781
assert return_annotation is functools.partial
782782

783+
@attr.s(slots=True)
784+
class C:
785+
@functools.cached_property
786+
def f(self) -> "wow":
787+
return "wow"
788+
789+
return_annotation = inspect.signature(C.f.fget).return_annotation
790+
assert return_annotation == "wow"
791+
783792

784793
def test_slots_cached_property_has_docstring():
785794
"""

0 commit comments

Comments
 (0)