add support for recursive datatypes
This commit is contained in:
parent
e8dd0ae47d
commit
7416bf3197
@ -30,6 +30,7 @@ from typing import (
|
|||||||
Optional,
|
Optional,
|
||||||
Set,
|
Set,
|
||||||
Tuple,
|
Tuple,
|
||||||
|
ForwardRef,
|
||||||
Type,
|
Type,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
@ -760,6 +761,12 @@ class Var(Generic[VAR_TYPE]):
|
|||||||
|
|
||||||
fixed_type = get_origin(var_type) or 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:
|
if fixed_type in types.UnionTypes:
|
||||||
inner_types = get_args(var_type)
|
inner_types = get_args(var_type)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user