EventChain.create accepts arbitrary kwargs (#4609)
Pass _var_data when creating LiteralVar Partial fixes for #4608
This commit is contained in:
parent
79611abdab
commit
fe9c02062d
@ -439,6 +439,7 @@ class EventChain(EventActionsMixin):
|
||||
value: EventType,
|
||||
args_spec: ArgsSpec | Sequence[ArgsSpec],
|
||||
key: Optional[str] = None,
|
||||
**event_chain_kwargs,
|
||||
) -> Union[EventChain, Var]:
|
||||
"""Create an event chain from a variety of input types.
|
||||
|
||||
@ -446,6 +447,7 @@ class EventChain(EventActionsMixin):
|
||||
value: The value to create the event chain from.
|
||||
args_spec: The args_spec of the event trigger being bound.
|
||||
key: The key of the event trigger being bound.
|
||||
**event_chain_kwargs: Additional kwargs to pass to the EventChain constructor.
|
||||
|
||||
Returns:
|
||||
The event chain.
|
||||
@ -464,6 +466,7 @@ class EventChain(EventActionsMixin):
|
||||
value=value.guess_type(),
|
||||
args_spec=args_spec,
|
||||
key=key,
|
||||
**event_chain_kwargs,
|
||||
)
|
||||
else:
|
||||
raise ValueError(
|
||||
@ -503,7 +506,9 @@ class EventChain(EventActionsMixin):
|
||||
result = call_event_fn(value, args_spec, key=key)
|
||||
if isinstance(result, Var):
|
||||
# Recursively call this function if the lambda returned an EventChain Var.
|
||||
return cls.create(value=result, args_spec=args_spec, key=key)
|
||||
return cls.create(
|
||||
value=result, args_spec=args_spec, key=key, **event_chain_kwargs
|
||||
)
|
||||
events = [*result]
|
||||
|
||||
# Otherwise, raise an error.
|
||||
@ -520,7 +525,7 @@ class EventChain(EventActionsMixin):
|
||||
return cls(
|
||||
events=events,
|
||||
args_spec=args_spec,
|
||||
event_actions={},
|
||||
**event_chain_kwargs,
|
||||
)
|
||||
|
||||
|
||||
|
@ -581,7 +581,7 @@ class Var(Generic[VAR_TYPE]):
|
||||
|
||||
# Try to pull the imports and hooks from contained values.
|
||||
if not isinstance(value, str):
|
||||
return LiteralVar.create(value)
|
||||
return LiteralVar.create(value, _var_data=_var_data)
|
||||
|
||||
if _var_is_string is False or _var_is_local is True:
|
||||
return cls(
|
||||
|
Loading…
Reference in New Issue
Block a user