Skip to content

Commit 9c19063

Browse files
committed
docs: update release notes and upgrade guide for v3 breaking changes
1 parent 00af5b0 commit 9c19063

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

docs/releases/3.0.0.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,20 @@ The `allow_event_without_transition` was previously configured as an init parame
486486
attribute.
487487

488488
Defaults to `False` in `StateMachine` class to preserve maximum backwards compatibility.
489+
490+
491+
### `States.from_enum` default `use_enum_instance=True`
492+
493+
The `use_enum_instance` parameter of `States.from_enum` now defaults to `True` (was `False` in 2.x).
494+
This means state values are the enum instances themselves, not their raw values.
495+
496+
If your code relies on raw enum values (e.g., integers), pass `use_enum_instance=False` explicitly.
497+
498+
499+
### Short registry names removed
500+
501+
State machine classes are now only registered by their fully-qualified name (`qualname`).
502+
The short-name lookup (by `cls.__name__`) that was deprecated since v0.8 has been removed.
503+
504+
If you use `get_machine_cls()` (e.g., via `MachineMixin`), make sure you pass the fully-qualified
505+
dotted path.

docs/releases/upgrade_2x_to_3.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ defaults. Review this guide to understand what changed and adopt the new APIs at
1717
5. Replace `sm.add_observer(...)` with `sm.add_listener(...)`.
1818
6. Update code that catches `TransitionNotAllowed` and accesses `.state` → use `.configuration`.
1919
7. Review `on` callbacks that query `is_active` or `current_state` during transitions.
20+
8. If using `States.from_enum`, note that `use_enum_instance` now defaults to `True`.
21+
9. If using `get_machine_cls()` with short names, switch to fully-qualified names.
2022

2123
---
2224

@@ -174,6 +176,51 @@ sm.add_listener(my_listener)
174176
```
175177

176178

179+
## `States.from_enum` default changed to `use_enum_instance=True`
180+
181+
In 2.x, `States.from_enum` defaulted to `use_enum_instance=False`, meaning state values were the
182+
raw enum values (e.g., integers). In 3.0, the default is `True`, so state values are the enum
183+
instances themselves.
184+
185+
**Before (2.x):**
186+
187+
```python
188+
states = States.from_enum(MyEnum, initial=MyEnum.start)
189+
# states.start.value == 1 (raw value)
190+
```
191+
192+
**After (3.0):**
193+
194+
```python
195+
states = States.from_enum(MyEnum, initial=MyEnum.start)
196+
# states.start.value == MyEnum.start (enum instance)
197+
```
198+
199+
If your code relies on raw enum values, pass `use_enum_instance=False` explicitly.
200+
201+
202+
## Short registry names removed
203+
204+
In 2.x, state machine classes were registered both by their fully-qualified name and their short
205+
class name. The short-name lookup was deprecated since v0.8 and has been removed in 3.0.
206+
207+
**Before (2.x):**
208+
209+
```python
210+
from statemachine.registry import get_machine_cls
211+
212+
cls = get_machine_cls("MyMachine") # short name — worked with warning
213+
```
214+
215+
**After (3.0):**
216+
217+
```python
218+
from statemachine.registry import get_machine_cls
219+
220+
cls = get_machine_cls("myapp.machines.MyMachine") # fully-qualified name
221+
```
222+
223+
177224
## Update `TransitionNotAllowed` exception handling
178225

179226
The `TransitionNotAllowed` exception now stores a `configuration` attribute (a set of states)

0 commit comments

Comments
 (0)