Skip to content
Snippets Groups Projects
Commit 681aba87 authored by Derval Guillaume's avatar Derval Guillaume
Browse files

Add sets as valid generic types in the AST checker

parent 5336fe02
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment