Skip to content

Commit

Permalink
If transition_to None do noting
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 2, 2024
1 parent 667af7a commit 4be6931
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/plumpy/base/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def _fire_state_event(self, hook: Hashable, state: Optional[State]) -> None:
def on_terminated(self) -> None:
"""Called when a terminal state is entered"""

def transition_to(self, new_state: Union[State, Type[State]], **kwargs: Any) -> None:
def transition_to(self, new_state: State | type[State] | None, **kwargs: Any) -> None:
"""Transite to the new state.
The new target state will be create lazily when the state is not yet instantiated,
Expand All @@ -322,6 +322,9 @@ def transition_to(self, new_state: Union[State, Type[State]], **kwargs: Any) ->
"""
assert not self._transitioning, 'Cannot call transition_to when already transitioning state'

if new_state is None:
return None

initial_state_label = self._state.LABEL if self._state is not None else None
label = None
try:
Expand Down

0 comments on commit 4be6931

Please sign in to comment.