From 7a4a185bdbb3f2175e55a4cd0f4dc02d9dd33c2e Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Tue, 7 Nov 2023 20:18:06 +0100 Subject: [PATCH] Fixed node_check for 3.8 --- backend/src/api/node_check.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/src/api/node_check.py b/backend/src/api/node_check.py index 8b2dfe357..c040a372f 100644 --- a/backend/src/api/node_check.py +++ b/backend/src/api/node_check.py @@ -5,7 +5,7 @@ import os import pathlib from enum import Enum -from typing import Any, Callable, NewType, Union, cast, get_args +from typing import Any, Callable, NewType, Tuple, Union, cast, get_args from .input import BaseInput from .output import BaseOutput @@ -70,6 +70,15 @@ def visit_BinOp(self, node: ast.BinOp): # noqa ) return super().visit_BinOp(node) + def visit_Subscript(self, node: ast.Subscript): # noqa + if isinstance(node.value, ast.Name) and node.value.id == "tuple": + return ast.Subscript( + value=ast.Name(id="Tuple", ctx=ast.Load()), + slice=node.slice, + ctx=ast.Load(), + ) + return super().visit_Subscript(node) + def compile_type_string(s: str, filename: str = ""): tree = ast.parse(s, filename, "eval") @@ -84,6 +93,7 @@ def eval_type(t: str | _Ty, __globals: dict[str, Any]): # `compile_type_string` adds `Union`, so we need it in scope local_scope = { "Union": Union, + "Tuple": Tuple, } try: