fix union types for vars (#4152)

This commit is contained in:
Khaleel Al-Adhami 2024-10-11 11:39:31 -07:00 committed by GitHub
parent 3da1a8d082
commit 210c1ed902
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -441,7 +441,7 @@ class Var(Generic[VAR_TYPE]):
if issubclass(output, NumberVar):
if fixed_type is not None:
if fixed_type is Union:
if fixed_type in types.UnionTypes:
inner_types = get_args(base_type)
if not all(issubclass(t, (int, float)) for t in inner_types):
raise TypeError(
@ -530,7 +530,7 @@ class Var(Generic[VAR_TYPE]):
fixed_type = get_origin(var_type) or var_type
if fixed_type is Union:
if fixed_type in types.UnionTypes:
inner_types = get_args(var_type)
if all(