Skip to content

Commit 329b209

Browse files
authored
Merge pull request #10 from gravy-jones-locker/hybrid-type-handling
Improved hybrid_property Type Handling
2 parents aa89eba + 468bf0c commit 329b209

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/strawberry_sqlalchemy_mapper/mapper.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,19 @@ def convert(type_: Any) -> Any:
639639
or "return" not in descriptor.__annotations__
640640
):
641641
raise HybridPropertyNotAnnotated(key)
642+
annotation = descriptor.__annotations__["return"]
643+
if isinstance(annotation, str):
644+
try:
645+
if "typing" in annotation:
646+
# Try to evaluate from existing typing imports
647+
annotation = annotation[7:]
648+
annotation = eval(annotation)
649+
except NameError:
650+
raise UnsupportedDescriptorType(key)
642651
self._add_annotation(
643652
type_,
644653
key,
645-
descriptor.__annotations__["return"],
654+
annotation,
646655
generated_field_keys,
647656
)
648657
else:

0 commit comments

Comments
 (0)