@@ -385,7 +385,7 @@ def _execute_transition_content(
385385
386386 return result
387387
388- def _enter_states (
388+ def _enter_states ( # noqa: C901
389389 self ,
390390 enabled_transitions : List [Transition ],
391391 trigger_data : TriggerData ,
@@ -425,8 +425,6 @@ def _enter_states(
425425 if self .sm .atomic_configuration_update :
426426 self .sm .configuration = new_configuration
427427
428- # Sort states to enter in entry order
429- # for state in sorted(states_to_enter, key=self.entry_order): # TODO: order of states_to_enter # noqa: E501
430428 for info in ordered_states :
431429 target = info .target
432430 assert target
@@ -437,6 +435,7 @@ def _enter_states(
437435 target = target ,
438436 )
439437
438+ logger .debug ("Entering state: %s" , target )
440439 # Add state to the configuration
441440 if not self .sm .atomic_configuration_update :
442441 self .sm .configuration |= {target }
@@ -453,9 +452,12 @@ def _enter_states(
453452 on_entry_result = self .sm ._callbacks .call (target .enter .key , * args , ** kwargs )
454453
455454 # Handle default initial states
456- # TODO: Handle default initial states
457- # if state in states_for_default_entry:
458- # self.execute_content(state.initial.transition)
455+ if target .id in {t .target .id for t in states_for_default_entry if t .target }:
456+ initial_transitions = [t for t in target .transitions if t .initial ]
457+ if len (initial_transitions ) == 1 :
458+ result += self .sm ._callbacks .call (
459+ initial_transitions [0 ].on .key , * args , ** kwargs
460+ )
459461
460462 # Handle default history states
461463 # if state.id in default_history_content:
0 commit comments