浏览代码

Use typing.get_type_hints instead of __annotations__ (#919)

Masen Furer 2 年之前
父节点
当前提交
d5977ffce4
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      pynecone/var.py

+ 4 - 2
pynecone/var.py

@@ -15,6 +15,7 @@ from typing import (
     Type,
     Union,
     _GenericAlias,  # type: ignore
+    get_type_hints,
 )
 
 from plotly.graph_objects import Figure
@@ -807,8 +808,9 @@ class ComputedVar(property, Var):
         Returns:
             The type of the var.
         """
-        if "return" in self.fget.__annotations__:
-            return self.fget.__annotations__["return"]
+        hints = get_type_hints(self.fget)
+        if "return" in hints:
+            return hints["return"]
         return Any