add check for class
This commit is contained in:
parent
5a0475d588
commit
aea5e5d113
@ -466,37 +466,38 @@ class Var(Generic[VAR_TYPE]):
|
|||||||
)
|
)
|
||||||
return ToArrayOperation.create(self, var_type or list)
|
return ToArrayOperation.create(self, var_type or list)
|
||||||
|
|
||||||
if issubclass(output, StringVar):
|
if inspect.isclass(output):
|
||||||
return ToStringOperation.create(self, var_type or str)
|
if issubclass(output, StringVar):
|
||||||
|
return ToStringOperation.create(self, var_type or str)
|
||||||
|
|
||||||
if issubclass(output, EventVar):
|
if issubclass(output, EventVar):
|
||||||
return ToEventVarOperation.create(self, var_type or EventSpec)
|
return ToEventVarOperation.create(self, var_type or EventSpec)
|
||||||
|
|
||||||
if issubclass(output, EventChainVar):
|
if issubclass(output, EventChainVar):
|
||||||
return ToEventChainVarOperation.create(self, var_type or EventChain)
|
return ToEventChainVarOperation.create(self, var_type or EventChain)
|
||||||
|
|
||||||
if issubclass(output, (ObjectVar, Base)):
|
if issubclass(output, (ObjectVar, Base)):
|
||||||
return ToObjectOperation.create(self, var_type or dict)
|
return ToObjectOperation.create(self, var_type or dict)
|
||||||
|
|
||||||
if issubclass(output, FunctionVar):
|
if issubclass(output, FunctionVar):
|
||||||
# if fixed_type is not None and not issubclass(fixed_type, Callable):
|
# if fixed_type is not None and not issubclass(fixed_type, Callable):
|
||||||
# raise TypeError(
|
# raise TypeError(
|
||||||
# f"Unsupported type {var_type} for FunctionVar. Must be Callable."
|
# f"Unsupported type {var_type} for FunctionVar. Must be Callable."
|
||||||
# )
|
# )
|
||||||
return ToFunctionOperation.create(self, var_type or Callable)
|
return ToFunctionOperation.create(self, var_type or Callable)
|
||||||
|
|
||||||
if issubclass(output, NoneVar):
|
if issubclass(output, NoneVar):
|
||||||
return ToNoneOperation.create(self)
|
return ToNoneOperation.create(self)
|
||||||
|
|
||||||
if dataclasses.is_dataclass(output):
|
if dataclasses.is_dataclass(output):
|
||||||
return ToObjectOperation.create(self, var_type or dict)
|
return ToObjectOperation.create(self, var_type or dict)
|
||||||
|
|
||||||
# If we can't determine the first argument, we just replace the _var_type.
|
# If we can't determine the first argument, we just replace the _var_type.
|
||||||
if not issubclass(output, Var) or var_type is None:
|
if not issubclass(output, Var) or var_type is None:
|
||||||
return dataclasses.replace(
|
return dataclasses.replace(
|
||||||
self,
|
self,
|
||||||
_var_type=output,
|
_var_type=output,
|
||||||
)
|
)
|
||||||
|
|
||||||
# We couldn't determine the output type to be any other Var type, so we replace the _var_type.
|
# We couldn't determine the output type to be any other Var type, so we replace the _var_type.
|
||||||
if var_type is not None:
|
if var_type is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user