From 681aba87d70ee36a9b03f07d5ee040dcb8ddb2e5 Mon Sep 17 00:00:00 2001
From: Derval Guillaume <gderval@uliege.be>
Date: Tue, 25 Jun 2024 11:55:16 +0200
Subject: [PATCH] Add sets as valid generic types in the AST checker

---
 src/gboml/ast/check.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gboml/ast/check.py b/src/gboml/ast/check.py
index 143562b..4003fd8 100644
--- a/src/gboml/ast/check.py
+++ b/src/gboml/ast/check.py
@@ -16,9 +16,9 @@ def _check_type(value, typ):
     if isinstance(typ, typing.ForwardRef):
         typ = eval(typ.__forward_arg__)
 
-    if isinstance(typ, types.GenericAlias) and typ.__origin__ == list:
+    if isinstance(typ, types.GenericAlias) and typ.__origin__ in [list, set]:
         subtyp = typing.get_args(typ)[0]
-        if not isinstance(value, list):
+        if not isinstance(value, typ.__origin__):
             raise NotOfType(f"{value} is not an instance of {typ}")
         for x in value:
             _check_type(x, subtyp)
-- 
GitLab