add support for recursive datatypes
This commit is contained in:
parent
e8dd0ae47d
commit
7416bf3197
@ -30,6 +30,7 @@ from typing import (
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
ForwardRef,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
@ -760,6 +761,12 @@ class Var(Generic[VAR_TYPE]):
|
||||
|
||||
fixed_type = get_origin(var_type) or var_type
|
||||
|
||||
if isinstance(fixed_type, ForwardRef):
|
||||
try:
|
||||
fixed_type = fixed_type._evaluate(globals(), locals(), set())
|
||||
except Exception:
|
||||
raise TypeError(f"Could not resolve ForwardRef: {fixed_type}")
|
||||
|
||||
if fixed_type in types.UnionTypes:
|
||||
inner_types = get_args(var_type)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user