Преглед на файлове

Python 3.10 tag issubclass bug: (#832)

Elijah Ahianyo преди 2 години
родител
ревизия
a52145e52a
променени са 2 файла, в които са добавени 12 реда и са изтрити 2 реда
  1. 1 1
      pynecone/components/tags/tag.py
  2. 11 1
      tests/components/test_tag.py

+ 1 - 1
pynecone/components/tags/tag.py

@@ -67,7 +67,7 @@ class Tag(Base):
         if isinstance(prop, Var):
             if not prop.is_local or prop.is_string:
                 return str(prop)
-            if issubclass(prop.type_, str):
+            if types._issubclass(prop.type_, str):
                 return format.json_dumps(prop.full_name)
             prop = prop.full_name
 

+ 11 - 1
tests/components/test_tag.py

@@ -1,4 +1,4 @@
-from typing import Dict
+from typing import Any, Dict
 
 import pytest
 
@@ -41,6 +41,16 @@ def mock_event(arg):
         ),
         ({"a": "red", "b": "blue"}, '{{"a": "red", "b": "blue"}}'),
         (BaseVar(name="var", type_="int"), "{var}"),
+        (
+            BaseVar(
+                name="_",
+                type_=Any,
+                state="",
+                is_local=True,
+                is_string=False,
+            ),
+            "{_}",
+        ),
         (BaseVar(name='state.colors["a"]', type_="str"), '{state.colors["a"]}'),
         ({"a": BaseVar(name="val", type_="str")}, '{{"a": val}}'),
         ({"a": BaseVar(name='"val"', type_="str")}, '{{"a": "val"}}'),