aaaa
This commit is contained in:
parent
aea5e5d113
commit
35569a46da
@ -439,34 +439,34 @@ class Var(Generic[VAR_TYPE]):
|
|||||||
):
|
):
|
||||||
return self.to(ObjectVar, output)
|
return self.to(ObjectVar, output)
|
||||||
|
|
||||||
if issubclass(output, BooleanVar):
|
if inspect.isclass(output):
|
||||||
return ToBooleanVarOperation.create(self)
|
if issubclass(output, BooleanVar):
|
||||||
|
return ToBooleanVarOperation.create(self)
|
||||||
|
|
||||||
if issubclass(output, NumberVar):
|
if issubclass(output, NumberVar):
|
||||||
if fixed_type is not None:
|
if fixed_type is not None:
|
||||||
if fixed_type is Union:
|
if fixed_type is Union:
|
||||||
inner_types = get_args(base_type)
|
inner_types = get_args(base_type)
|
||||||
if not all(issubclass(t, (int, float)) for t in inner_types):
|
if not all(issubclass(t, (int, float)) for t in inner_types):
|
||||||
|
raise TypeError(
|
||||||
|
f"Unsupported type {var_type} for NumberVar. Must be int or float."
|
||||||
|
)
|
||||||
|
|
||||||
|
elif not issubclass(fixed_type, (int, float)):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f"Unsupported type {var_type} for NumberVar. Must be int or float."
|
f"Unsupported type {var_type} for NumberVar. Must be int or float."
|
||||||
)
|
)
|
||||||
|
return ToNumberVarOperation.create(self, var_type or float)
|
||||||
|
|
||||||
elif not issubclass(fixed_type, (int, float)):
|
if issubclass(output, ArrayVar):
|
||||||
|
if fixed_type is not None and not issubclass(
|
||||||
|
fixed_type, (list, tuple, set)
|
||||||
|
):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f"Unsupported type {var_type} for NumberVar. Must be int or float."
|
f"Unsupported type {var_type} for ArrayVar. Must be list, tuple, or set."
|
||||||
)
|
)
|
||||||
return ToNumberVarOperation.create(self, var_type or float)
|
return ToArrayOperation.create(self, var_type or list)
|
||||||
|
|
||||||
if issubclass(output, ArrayVar):
|
|
||||||
if fixed_type is not None and not issubclass(
|
|
||||||
fixed_type, (list, tuple, set)
|
|
||||||
):
|
|
||||||
raise TypeError(
|
|
||||||
f"Unsupported type {var_type} for ArrayVar. Must be list, tuple, or set."
|
|
||||||
)
|
|
||||||
return ToArrayOperation.create(self, var_type or list)
|
|
||||||
|
|
||||||
if inspect.isclass(output):
|
|
||||||
if issubclass(output, StringVar):
|
if issubclass(output, StringVar):
|
||||||
return ToStringOperation.create(self, var_type or str)
|
return ToStringOperation.create(self, var_type or str)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user