Skip to content

Commit d3ff328

Browse files
committed
Merge tag 'v2.3.0' into develop
*June 7, 2024* This release has a high expected feature, we're adding [asynchronous support](../async.md), and enhancing overall functionality. In fact, the approach we took was to go all the way down changing the internals of the library to be fully async, keeping only the current external API as a thin sync/async adapter. StateMachine 2.3.0 supports Python 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12. We've fixed a bug on the package declaration that was preventing users from Python 3.7 to install the latest version. This release introduces native coroutine support using asyncio, enabling seamless integration with asynchronous code. Now you can send and await for events, and also write async {ref}`Actions`, {ref}`Conditions` and {ref}`Validators`. ```{seealso} See {ref}`sphx_glr_auto_examples_air_conditioner_machine.py` for an example of async code with a state machine. ``` ```py >>> class AsyncStateMachine(StateMachine): ... initial = State('Initial', initial=True) ... final = State('Final', final=True) ... ... advance = initial.to(final) >>> async def run_sm(): ... sm = AsyncStateMachine() ... await sm.advance() ... print(sm.current_state) >>> asyncio.run(run_sm()) Final ```
2 parents c248a43 + d011271 commit d3ff328

5 files changed

Lines changed: 103 additions & 68 deletions

File tree

docs/releases/2.3.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# StateMachine 2.3.0
22

3-
*Not released yet*
3+
*June 7, 2024*
44

55
## What's new in 2.3.0
66

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "python-statemachine"
3-
version = "2.2.0"
3+
version = "2.3.0"
44
description = "Python Finite State Machines made easy."
55
authors = ["Fernando Macedo <fgmacedo@gmail.com>"]
66
maintainers = [

statemachine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
__author__ = """Fernando Macedo"""
55
__email__ = "fgmacedo@gmail.com"
6-
__version__ = "2.2.0"
6+
__version__ = "2.3.0"
77

88
__all__ = ["StateMachine", "State"]
Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,80 @@
11
# This file is distributed under the same license as the PROJECT project.
2-
# Fernando Macedo <fgmacedo@gmail.com>, 2023.
2+
# Fernando Macedo <fgmacedo@gmail.com>, 2024.
33
#
44
msgid ""
55
msgstr ""
6-
"Project-Id-Version: 2.1.0\n"
6+
"Project-Id-Version: 2.3.0\n"
77
"Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
88
"POT-Creation-Date: 2023-03-04 16:10-0300\n"
9-
"PO-Revision-Date: 2023-03-04 16:10-0300\n"
9+
"PO-Revision-Date: 2024-06-07 17:41-0300\n"
1010
"Last-Translator: Fernando Macedo <fgmacedo@gmail.com>\n"
1111
"MIME-Version: 1.0\n"
1212
"Content-Type: text/plain; charset=utf-8\n"
1313
"Content-Transfer-Encoding: 8bit\n"
1414
"Generated-By: Babel 2.12.1\n"
1515

16-
#: statemachine/callbacks.py:56
17-
msgid "Callback {!r} not property configured."
18-
msgstr ""
19-
20-
#: statemachine/dispatcher.py:35
16+
#: statemachine/callbacks.py:289
2117
msgid "Did not found name '{}' from model or statemachine"
2218
msgstr ""
2319

24-
#: statemachine/exceptions.py:17
20+
#: statemachine/exceptions.py:23
2521
msgid "{!r} is not a valid state value."
2622
msgstr ""
2723

28-
#: statemachine/exceptions.py:31
24+
#: statemachine/exceptions.py:37
2925
msgid "Can't {} when in {}."
3026
msgstr ""
3127

32-
#: statemachine/factory.py:35
33-
msgid ""
34-
"There should be one and only one initial state. Your currently have "
35-
"these: {!r}"
28+
#: statemachine/factory.py:73
29+
msgid "There are no states."
30+
msgstr ""
31+
32+
#: statemachine/factory.py:76
33+
msgid "There are no events."
3634
msgstr ""
3735

38-
#: statemachine/factory.py:51
36+
#: statemachine/factory.py:88
3937
msgid ""
40-
"There are unreachable states. The statemachine graph should have a single"
41-
" component. Disconnected states: {}"
38+
"There should be one and only one initial state. You currently have these:"
39+
" {!r}"
4240
msgstr ""
4341

44-
#: statemachine/factory.py:69
45-
msgid "There are no states."
42+
#: statemachine/factory.py:101
43+
msgid "Cannot declare transitions from final state. Invalid state(s): {}"
4644
msgstr ""
4745

48-
#: statemachine/factory.py:72
49-
msgid "There are no events."
46+
#: statemachine/factory.py:109
47+
msgid ""
48+
"All non-final states should have at least one outgoing transition. These "
49+
"states have no outgoing transition: {!r}"
5050
msgstr ""
5151

52-
#: statemachine/factory.py:82
53-
msgid "Cannot declare transitions from final state. Invalid state(s): {}"
52+
#: statemachine/factory.py:123
53+
msgid ""
54+
"All non-final states should have at least one path to a final state. "
55+
"These states have no path to a final state: {!r}"
5456
msgstr ""
5557

56-
#: statemachine/mixins.py:30
58+
#: statemachine/factory.py:147
59+
msgid ""
60+
"There are unreachable states. The statemachine graph should have a single"
61+
" component. Disconnected states: {}"
62+
msgstr ""
63+
64+
#: statemachine/mixins.py:23
5765
msgid "{!r} is not a valid state machine name."
5866
msgstr ""
5967

60-
#: statemachine/state.py:148
68+
#: statemachine/state.py:152
6169
msgid "State overriding is not allowed. Trying to add '{}' to {}"
6270
msgstr ""
6371

64-
#: statemachine/statemachine.py:48
72+
#: statemachine/statemachine.py:86
6573
msgid "There are no states or transitions."
6674
msgstr ""
75+
76+
#: statemachine/statemachine.py:249
77+
msgid ""
78+
"There's no current state set. In async code, did you activate the initial"
79+
" state? (e.g., `await sm.activate_initial_state()`)"
80+
msgstr ""
Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,91 @@
1-
# This file is distributed under the same license as the PROJECT project.
2-
# Fernando Macedo <fgmacedo@gmail.com>, 2023.
1+
# This file is distributed under the same license as the project.
2+
# Fernando Macedo <fgmacedo@gmail.com>, 2024.
33
#
44
msgid ""
55
msgstr ""
6-
"Project-Id-Version: 2.1.0\n"
6+
"Project-Id-Version: 2.3.0\n"
77
"Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
88
"POT-Creation-Date: 2023-03-04 16:10-0300\n"
9-
"PO-Revision-Date: 2023-03-04 16:10-0300\n"
9+
"PO-Revision-Date: 2024-06-07 17:41-0300\n"
1010
"Last-Translator: Fernando Macedo <fgmacedo@gmail.com>\n"
11+
"Language-Team: LANGUAGE <LL@li.org>\n"
1112
"MIME-Version: 1.0\n"
1213
"Content-Type: text/plain; charset=utf-8\n"
1314
"Content-Transfer-Encoding: 8bit\n"
14-
"Generated-By: Babel 2.12.1\n"
15+
"Generated-By: Babel 2.14.0\n"
1516

16-
#: statemachine/callbacks.py:56
17-
msgid "Callback {!r} not property configured."
18-
msgstr "Callback {!r} não está configurado corretamente."
19-
20-
#: statemachine/dispatcher.py:35
17+
#: statemachine/callbacks.py:289
2118
msgid "Did not found name '{}' from model or statemachine"
22-
msgstr "Não foi encontrado o nome '{}' no modelo ou na máquina de estados"
19+
msgstr "Não encontrou o nome '{}' no modelo ou na máquina de estados"
2320

24-
#: statemachine/exceptions.py:17
21+
#: statemachine/exceptions.py:23
2522
msgid "{!r} is not a valid state value."
2623
msgstr "{!r} não é um valor de estado válido."
2724

28-
#: statemachine/exceptions.py:31
25+
#: statemachine/exceptions.py:37
2926
msgid "Can't {} when in {}."
30-
msgstr "Não é possível {} quando em {}."
31-
32-
#: statemachine/factory.py:35
33-
msgid ""
34-
"There should be one and only one initial state. Your currently have "
35-
"these: {!r}"
36-
msgstr ""
37-
"Deve haver um e apenas um estado inicial. Atualmente, você tem "
38-
"os seguintes: {!r}"
27+
msgstr "Não é possível {} quando está em {}."
3928

40-
#: statemachine/factory.py:51
41-
msgid ""
42-
"There are unreachable states. The statemachine graph should have a single"
43-
" component. Disconnected states: {}"
44-
msgstr ""
45-
"Há estados inalcançáveis. O grafo da máquina de estados deve ter apenas um"
46-
" componente. Estados desconectados: {}"
47-
48-
#: statemachine/factory.py:69
29+
#: statemachine/factory.py:73
4930
msgid "There are no states."
5031
msgstr "Não há estados."
5132

52-
#: statemachine/factory.py:72
33+
#: statemachine/factory.py:76
5334
msgid "There are no events."
5435
msgstr "Não há eventos."
5536

56-
#: statemachine/factory.py:82
37+
#: statemachine/factory.py:88
38+
msgid ""
39+
"There should be one and only one initial state. You currently have these:"
40+
" {!r}"
41+
msgstr "Deve haver um e apenas um estado inicial. Você atualmente tem estes: {!r}"
42+
43+
#: statemachine/factory.py:101
5744
msgid "Cannot declare transitions from final state. Invalid state(s): {}"
58-
msgstr "Não é possível declarar transições a partir do estado final. Estado(s) inválido(s): {}"
45+
msgstr ""
46+
"Não é possível declarar transições a partir do estado final. Estado(s) "
47+
"inválido(s): {}"
48+
49+
#: statemachine/factory.py:109
50+
msgid ""
51+
"All non-final states should have at least one outgoing transition. These "
52+
"states have no outgoing transition: {!r}"
53+
msgstr ""
54+
"Todos os estados não finais devem ter pelo menos uma transição de saída. "
55+
"Esses estados não têm transição de saída: {!r}"
5956

60-
#: statemachine/mixins.py:30
57+
#: statemachine/factory.py:123
58+
msgid ""
59+
"All non-final states should have at least one path to a final state. "
60+
"These states have no path to a final state: {!r}"
61+
msgstr ""
62+
"Todos os estados não finais devem ter pelo menos um caminho para um "
63+
"estado final. Esses estados não têm caminho para um estado final: {!r}"
64+
65+
#: statemachine/factory.py:147
66+
msgid ""
67+
"There are unreachable states. The statemachine graph should have a single"
68+
" component. Disconnected states: {}"
69+
msgstr ""
70+
"Há estados inacessíveis. O gráfico da máquina de estados deve ter um "
71+
"único componente. Estados desconectados: {}"
72+
73+
#: statemachine/mixins.py:23
6174
msgid "{!r} is not a valid state machine name."
62-
msgstr "{!r} não é um nome válido para a máquina de estados."
75+
msgstr "{!r} não é um nome válido para uma máquina de estados."
6376

64-
#: statemachine/state.py:148
77+
#: statemachine/state.py:152
6578
msgid "State overriding is not allowed. Trying to add '{}' to {}"
66-
msgstr "A substituição de estado não é permitida. Tentando adicionar '{}' a {}"
79+
msgstr "Sobrescrever estados não é permitido. Tentando adicionar '{}' a {}"
6780

68-
#: statemachine/statemachine.py:48
81+
#: statemachine/statemachine.py:86
6982
msgid "There are no states or transitions."
7083
msgstr "Não há estados ou transições."
84+
85+
#: statemachine/statemachine.py:249
86+
msgid ""
87+
"There's no current state set. In async code, did you activate the initial"
88+
" state? (e.g., `await sm.activate_initial_state()`)"
89+
msgstr ""
90+
"Não há estado atual definido. No código assíncrono, você ativou o estado"
91+
" inicial? (por exemplo, `await sm.activate_initial_state()`)"

0 commit comments

Comments
 (0)