Skip to content

Commit b7a46e5

Browse files
authored
docs: improve StateChart docstrings and complete 3.1.0 release notes (#609)
1 parent 386980a commit b7a46e5

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

docs/releases/3.1.0.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,14 @@ machine instance concurrently. This is now documented in the
170170
The docstring also now includes a `deprecated` directive for Sphinx autodoc.
171171
[#604](https://github.com/fgmacedo/python-statemachine/issues/604).
172172

173+
- `Configuration.add()`/`discard()` now write through the model setter, ensuring state
174+
changes are persisted correctly on domain models (e.g., Django models with custom setters).
175+
Previously the configuration was updated in-place without notifying the model layer.
176+
[#596](https://github.com/fgmacedo/python-statemachine/pull/596).
177+
178+
- `States.from_enum()` now works correctly inside compound and parallel states. Previously
179+
the states were silently not collected when used as a nested state declaration.
180+
[#607](https://github.com/fgmacedo/python-statemachine/pull/607),
181+
fixes [#606](https://github.com/fgmacedo/python-statemachine/issues/606).
182+
173183
## Misc in 3.1.0

statemachine/statemachine.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ class StateChart(Generic[TModel], metaclass=StateMachineMetaclass):
5555
start_value: An optional start state value if there's no current state assigned
5656
on the :ref:`domain models`. Default: ``None``.
5757
58-
listeners: An optional list of objects that provies attributes to be used as callbacks.
58+
listeners: An optional list of objects that provides attributes to be used as callbacks.
5959
See :ref:`listeners` for more details.
6060
61+
**kwargs: Additional keyword arguments available for dependency injection into
62+
callbacks. These are passed to class listener ``setup()`` methods and to the
63+
initial activation callbacks (e.g. ``on_enter_<state>``).
64+
6165
"""
6266

6367
TransitionNotAllowed = TransitionNotAllowed
@@ -145,9 +149,13 @@ def __init__(
145149
**kwargs: Any,
146150
):
147151
self.model: TModel = model if model is not None else Model() # type: ignore[assignment]
148-
self.history_values: Dict[
149-
str, List[State]
150-
] = {} # Mapping of compound states to last active state(s).
152+
"""The external model object that holds domain state, or an internal
153+
:class:`Model` instance when none is provided. See :ref:`domain models`."""
154+
155+
self.history_values: Dict[str, List[State]] = {}
156+
"""Mapping from compound state IDs to the list of states that were active
157+
the last time that compound state was exited. Used by history pseudo-states
158+
to restore previous configurations."""
151159
self.state_field = state_field
152160
self.start_configuration_values = (
153161
[start_value] if start_value is not None else list(self.start_configuration_values)
@@ -416,6 +424,7 @@ def current_state(self, value):
416424

417425
@property
418426
def events(self) -> "List[Event]":
427+
"""List of all :ref:`Event` instances declared on this state machine."""
419428
return [getattr(self, event) for event in self.__class__._events]
420429

421430
@property

0 commit comments

Comments
 (0)