Skip to content

Commit 233d25f

Browse files
authored
refac: Removing all internal references in code and docs to deprecated features (#309)
1 parent 6eb2772 commit 233d25f

26 files changed

Lines changed: 160 additions & 184 deletions

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Define your state machine:
9191
... return "Running {} from {} to {}{}".format(
9292
... event_data.event,
9393
... event_data.transition.source.id,
94-
... event_data.transition.destination.id,
94+
... event_data.transition.target.id,
9595
... message,
9696
... )
9797
...

docs/actions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ Actions and Guards will be executed in the following order:
299299

300300
- `on_exit_state()`
301301

302-
- `on_exit_<state_identifier>()`
302+
- `on_exit_<state.id>()`
303303

304304
- `on_transition()`
305305

306306
- `on_<event>()`
307307

308308
- `on_enter_state()`
309309

310-
- `on_enter_<state_identifier>()`
310+
- `on_enter_<state.id>()`
311311

312312
- `after_<event>()`
313313

docs/auto_examples/traffic_light_machine.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from statemachine import StateMachine, State\n\n\nclass TrafficLightMachine(StateMachine):\n \"A traffic light machine\"\n green = State(\"Green\", initial=True)\n yellow = State(\"Yellow\")\n red = State(\"Red\")\n\n cycle = green.to(yellow) | yellow.to(red) | red.to(green)\n\n def on_cycle(self, event_data=None):\n return \"Running {} from {} to {}\".format(\n event_data.event,\n event_data.transition.source.identifier,\n event_data.transition.destination.identifier,\n )"
29+
"from statemachine import StateMachine, State\n\n\nclass TrafficLightMachine(StateMachine):\n \"A traffic light machine\"\n green = State(\"Green\", initial=True)\n yellow = State(\"Yellow\")\n red = State(\"Red\")\n\n cycle = green.to(yellow) | yellow.to(red) | red.to(green)\n\n def on_cycle(self, event_data=None):\n return \"Running {} from {} to {}\".format(\n event_data.event,\n event_data.source.id,\n event_data.target.id,\n )"
3030
]
3131
}
3232
],

docs/auto_examples/traffic_light_machine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ class TrafficLightMachine(StateMachine):
2020
def on_cycle(self, event_data=None):
2121
return "Running {} from {} to {}".format(
2222
event_data.event,
23-
event_data.transition.source.identifier,
24-
event_data.transition.destination.identifier,
23+
event_data.source.id,
24+
event_data.target.id,
2525
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0af5cdeaa4a1943efbf042b8716ba3f4
1+
19e658cb602d79aa1479dce8e9def1b3

docs/auto_examples/traffic_light_machine.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Demonstrates the concept of ``cycle`` states.
5353
def on_cycle(self, event_data=None):
5454
return "Running {} from {} to {}".format(
5555
event_data.event,
56-
event_data.transition.source.identifier,
57-
event_data.transition.destination.identifier,
56+
event_data.source.id,
57+
event_data.target.id,
5858
)
5959
6060

docs/examples/traffic_light_machine.ipynb

Lines changed: 9 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
" def on_cycle(self, event_data=None):\n",
3434
" return \"Running {} from {} to {}\".format(\n",
3535
" event_data.event.name,\n",
36-
" event_data.transition.source.identifier,\n",
37-
" event_data.transition.destination.identifier,\n",
36+
" event_data.transition.source.id,\n",
37+
" event_data.transition.target.id,\n",
3838
" )\n",
3939
" \n",
4040
" def on_enter_state(self):\n",
@@ -52,76 +52,7 @@
5252
"outputs": [
5353
{
5454
"data": {
55-
"image/svg+xml": [
56-
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
57-
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
58-
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
59-
"<!-- Generated by graphviz version 2.40.1 (20161225.0304)\n",
60-
" -->\n",
61-
"<!-- Title: list Pages: 1 -->\n",
62-
"<svg width=\"543pt\" height=\"93pt\"\n",
63-
" viewBox=\"0.00 0.00 543.00 93.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
64-
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 89)\">\n",
65-
"<title>list</title>\n",
66-
"<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"-4,4 -4,-89 539,-89 539,4 -4,4\"/>\n",
67-
"<text text-anchor=\"middle\" x=\"267.5\" y=\"-7\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">TrafficLightMachine</text>\n",
68-
"<!-- i -->\n",
69-
"<g id=\"node1\" class=\"node\">\n",
70-
"<title>i</title>\n",
71-
"<ellipse fill=\"#000000\" stroke=\"#000000\" cx=\"7\" cy=\"-37\" rx=\"7\" ry=\"7\"/>\n",
72-
"<text text-anchor=\"middle\" x=\"7\" y=\"-36.7\" font-family=\"Times,serif\" font-size=\"1.00\" fill=\"#000000\">i</text>\n",
73-
"</g>\n",
74-
"<!-- green -->\n",
75-
"<g id=\"node2\" class=\"node\">\n",
76-
"<title>green</title>\n",
77-
"<path fill=\"#40e0d0\" stroke=\"#000000\" stroke-width=\"2\" d=\"M144,-55C144,-55 63,-55 63,-55 57,-55 51,-49 51,-43 51,-43 51,-31 51,-31 51,-25 57,-19 63,-19 63,-19 144,-19 144,-19 150,-19 156,-25 156,-31 156,-31 156,-43 156,-43 156,-49 150,-55 144,-55\"/>\n",
78-
"<text text-anchor=\"middle\" x=\"103.5\" y=\"-40\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">Green</text>\n",
79-
"<text text-anchor=\"middle\" x=\"103.5\" y=\"-29\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">entry / on_enter_state</text>\n",
80-
"</g>\n",
81-
"<!-- i&#45;&gt;green -->\n",
82-
"<g id=\"edge1\" class=\"edge\">\n",
83-
"<title>i&#45;&gt;green</title>\n",
84-
"<path fill=\"none\" stroke=\"#0000ff\" d=\"M14.2532,-37C20.4952,-37 30.1691,-37 40.8829,-37\"/>\n",
85-
"<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"40.9459,-40.5001 50.9459,-37 40.9459,-33.5001 40.9459,-40.5001\"/>\n",
86-
"</g>\n",
87-
"<!-- yellow -->\n",
88-
"<g id=\"node3\" class=\"node\">\n",
89-
"<title>yellow</title>\n",
90-
"<path fill=\"#ffffff\" stroke=\"#000000\" d=\"M304,-85C304,-85 223,-85 223,-85 217,-85 211,-79 211,-73 211,-73 211,-61 211,-61 211,-55 217,-49 223,-49 223,-49 304,-49 304,-49 310,-49 316,-55 316,-61 316,-61 316,-73 316,-73 316,-79 310,-85 304,-85\"/>\n",
91-
"<text text-anchor=\"middle\" x=\"263.5\" y=\"-70\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">Yellow</text>\n",
92-
"<text text-anchor=\"middle\" x=\"263.5\" y=\"-59\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">entry / on_enter_state</text>\n",
93-
"</g>\n",
94-
"<!-- green&#45;&gt;yellow -->\n",
95-
"<g id=\"edge2\" class=\"edge\">\n",
96-
"<title>green&#45;&gt;yellow</title>\n",
97-
"<path fill=\"none\" stroke=\"#0000ff\" d=\"M156.3334,-46.9063C170.6072,-49.5826 186.1902,-52.5044 200.9416,-55.2703\"/>\n",
98-
"<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"200.5211,-58.7524 210.9949,-57.1553 201.8112,-51.8723 200.5211,-58.7524\"/>\n",
99-
"<text text-anchor=\"middle\" x=\"183.5\" y=\"-54.8\" font-family=\"Times,serif\" font-size=\"9.00\" fill=\"#000000\">cycle</text>\n",
100-
"</g>\n",
101-
"<!-- red -->\n",
102-
"<g id=\"node4\" class=\"node\">\n",
103-
"<title>red</title>\n",
104-
"<path fill=\"#ffffff\" stroke=\"#000000\" d=\"M523,-55C523,-55 383,-55 383,-55 377,-55 371,-49 371,-43 371,-43 371,-31 371,-31 371,-25 377,-19 383,-19 383,-19 523,-19 523,-19 529,-19 535,-25 535,-31 535,-31 535,-43 535,-43 535,-49 529,-55 523,-55\"/>\n",
105-
"<text text-anchor=\"middle\" x=\"453\" y=\"-40\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">Red</text>\n",
106-
"<text text-anchor=\"middle\" x=\"453\" y=\"-29\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">entry / on_enter_state, on_enter_red</text>\n",
107-
"</g>\n",
108-
"<!-- yellow&#45;&gt;red -->\n",
109-
"<g id=\"edge4\" class=\"edge\">\n",
110-
"<title>yellow&#45;&gt;red</title>\n",
111-
"<path fill=\"none\" stroke=\"#0000ff\" d=\"M316.0347,-58.6832C329.9618,-56.4783 345.4185,-54.0314 360.7861,-51.5985\"/>\n",
112-
"<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"361.5254,-55.0251 370.8551,-50.0045 360.4308,-48.1112 361.5254,-55.0251\"/>\n",
113-
"<text text-anchor=\"middle\" x=\"343.5\" y=\"-57.8\" font-family=\"Times,serif\" font-size=\"9.00\" fill=\"#000000\">cycle</text>\n",
114-
"</g>\n",
115-
"<!-- red&#45;&gt;green -->\n",
116-
"<g id=\"edge3\" class=\"edge\">\n",
117-
"<title>red&#45;&gt;green</title>\n",
118-
"<path fill=\"none\" stroke=\"#0000ff\" d=\"M370.8015,-32.1163C352.753,-31.2349 333.737,-30.4528 316,-30 269.3485,-28.809 257.642,-28.483 211,-30 196.4955,-30.4717 180.9077,-31.3006 166.2257,-32.2268\"/>\n",
119-
"<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"165.9807,-28.7352 156.2304,-32.8803 166.4375,-35.7203 165.9807,-28.7352\"/>\n",
120-
"<text text-anchor=\"middle\" x=\"263.5\" y=\"-32.8\" font-family=\"Times,serif\" font-size=\"9.00\" fill=\"#000000\">cycle</text>\n",
121-
"</g>\n",
122-
"</g>\n",
123-
"</svg>\n"
124-
],
55+
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.40.1 (20161225.0304)\n -->\n<!-- Title: list Pages: 1 -->\n<svg width=\"543pt\" height=\"93pt\"\n viewBox=\"0.00 0.00 543.00 93.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 89)\">\n<title>list</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"-4,4 -4,-89 539,-89 539,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"267.5\" y=\"-7\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">TrafficLightMachine</text>\n<!-- i -->\n<g id=\"node1\" class=\"node\">\n<title>i</title>\n<ellipse fill=\"#000000\" stroke=\"#000000\" cx=\"7\" cy=\"-37\" rx=\"7\" ry=\"7\"/>\n<text text-anchor=\"middle\" x=\"7\" y=\"-36.7\" font-family=\"Times,serif\" font-size=\"1.00\" fill=\"#000000\">i</text>\n</g>\n<!-- green -->\n<g id=\"node2\" class=\"node\">\n<title>green</title>\n<path fill=\"#40e0d0\" stroke=\"#000000\" stroke-width=\"2\" d=\"M144,-55C144,-55 63,-55 63,-55 57,-55 51,-49 51,-43 51,-43 51,-31 51,-31 51,-25 57,-19 63,-19 63,-19 144,-19 144,-19 150,-19 156,-25 156,-31 156,-31 156,-43 156,-43 156,-49 150,-55 144,-55\"/>\n<text text-anchor=\"middle\" x=\"103.5\" y=\"-40\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">Green</text>\n<text text-anchor=\"middle\" x=\"103.5\" y=\"-29\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">entry / on_enter_state</text>\n</g>\n<!-- i&#45;&gt;green -->\n<g id=\"edge1\" class=\"edge\">\n<title>i&#45;&gt;green</title>\n<path fill=\"none\" stroke=\"#0000ff\" d=\"M14.2532,-37C20.4952,-37 30.1691,-37 40.8829,-37\"/>\n<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"40.9459,-40.5001 50.9459,-37 40.9459,-33.5001 40.9459,-40.5001\"/>\n</g>\n<!-- yellow -->\n<g id=\"node3\" class=\"node\">\n<title>yellow</title>\n<path fill=\"#ffffff\" stroke=\"#000000\" d=\"M304,-85C304,-85 223,-85 223,-85 217,-85 211,-79 211,-73 211,-73 211,-61 211,-61 211,-55 217,-49 223,-49 223,-49 304,-49 304,-49 310,-49 316,-55 316,-61 316,-61 316,-73 316,-73 316,-79 310,-85 304,-85\"/>\n<text text-anchor=\"middle\" x=\"263.5\" y=\"-70\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">Yellow</text>\n<text text-anchor=\"middle\" x=\"263.5\" y=\"-59\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">entry / on_enter_state</text>\n</g>\n<!-- green&#45;&gt;yellow -->\n<g id=\"edge2\" class=\"edge\">\n<title>green&#45;&gt;yellow</title>\n<path fill=\"none\" stroke=\"#0000ff\" d=\"M156.3334,-46.9063C170.6072,-49.5826 186.1902,-52.5044 200.9416,-55.2703\"/>\n<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"200.5211,-58.7524 210.9949,-57.1553 201.8112,-51.8723 200.5211,-58.7524\"/>\n<text text-anchor=\"middle\" x=\"183.5\" y=\"-54.8\" font-family=\"Times,serif\" font-size=\"9.00\" fill=\"#000000\">cycle</text>\n</g>\n<!-- red -->\n<g id=\"node4\" class=\"node\">\n<title>red</title>\n<path fill=\"#ffffff\" stroke=\"#000000\" d=\"M523,-55C523,-55 383,-55 383,-55 377,-55 371,-49 371,-43 371,-43 371,-31 371,-31 371,-25 377,-19 383,-19 383,-19 523,-19 523,-19 529,-19 535,-25 535,-31 535,-31 535,-43 535,-43 535,-49 529,-55 523,-55\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-40\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">Red</text>\n<text text-anchor=\"middle\" x=\"453\" y=\"-29\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#000000\">entry / on_enter_state, on_enter_red</text>\n</g>\n<!-- yellow&#45;&gt;red -->\n<g id=\"edge4\" class=\"edge\">\n<title>yellow&#45;&gt;red</title>\n<path fill=\"none\" stroke=\"#0000ff\" d=\"M316.0347,-58.6832C329.9618,-56.4783 345.4185,-54.0314 360.7861,-51.5985\"/>\n<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"361.5254,-55.0251 370.8551,-50.0045 360.4308,-48.1112 361.5254,-55.0251\"/>\n<text text-anchor=\"middle\" x=\"343.5\" y=\"-57.8\" font-family=\"Times,serif\" font-size=\"9.00\" fill=\"#000000\">cycle</text>\n</g>\n<!-- red&#45;&gt;green -->\n<g id=\"edge3\" class=\"edge\">\n<title>red&#45;&gt;green</title>\n<path fill=\"none\" stroke=\"#0000ff\" d=\"M370.8015,-32.1163C352.753,-31.2349 333.737,-30.4528 316,-30 269.3485,-28.809 257.642,-28.483 211,-30 196.4955,-30.4717 180.9077,-31.3006 166.2257,-32.2268\"/>\n<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"165.9807,-28.7352 156.2304,-32.8803 166.4375,-35.7203 165.9807,-28.7352\"/>\n<text text-anchor=\"middle\" x=\"263.5\" y=\"-32.8\" font-family=\"Times,serif\" font-size=\"9.00\" fill=\"#000000\">cycle</text>\n</g>\n</g>\n</svg>\n",
12556
"text/plain": [
12657
"TrafficLightMachine(model=Model(state=green), state_field='state', current_state='green')"
12758
]
@@ -153,7 +84,12 @@
15384
"name": "python",
15485
"nbconvert_exporter": "python",
15586
"pygments_lexer": "ipython3",
156-
"version": "3.8.1"
87+
"version": "3.8.1 (default, Dec 21 2019, 08:49:15) \n[GCC 7.4.0]"
88+
},
89+
"vscode": {
90+
"interpreter": {
91+
"hash": "94f282d658e0bedff3dcf13b7bf6b556458ab0ae44b675c100fba6f748b54e7d"
92+
}
15793
}
15894
},
15995
"nbformat": 4,

docs/releases/0.9.0.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ Parameters sent with the event trigger will now be propagated to the transition
2626

2727
>>> sm = CampaignMachine()
2828

29-
>>> sm.run("produce", approver="Gandalf") # event oriented
30-
Approved by: Gandalf
31-
3229
>>> sm.produce(approver="Aragorn") # imperatite
3330
Approved by: Aragorn
3431

docs/releases/1.0.0.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,11 @@ See {ref}`dynamic-dispatch` for more details.
9090
## Backwards incompatible changes in 1.0
9191

9292

93-
### Multiple destinations from the same origin state
93+
### Multiple targets from the same origin state
9494

9595
Prior to this release, as we didn't have {ref}`validators-and-guards`, there wasn't an elegant way
96-
to declare multiples destinations starting from the same pair (event, state). But the library
97-
allowed a near-hackish way, by declaring a destination state as the result of the `on_<event>`
98-
callback.
96+
to declare multiples target states starting from the same pair (event, state). But the library
97+
allowed a near-hackish way, by declaring a target state as the result of the `on_<event>` callback.
9998

10099
So, the previous code (not valid anymore):
101100

@@ -201,8 +200,9 @@ with pytest.raises(exceptions.InvalidDefinition):
201200
{ref}`dynamic-dispatch` rules. Previously it only accepted the `state` param.
202201
- `Transition.__init__` param `on_execute` renamed to simply `on`, and now follows the
203202
{ref}`dynamic-dispatch`.
204-
- `Transition.destinations` removed in favor of `Transition.destination`. Now each transition only
205-
points to a unique target. Each `source->destination` pair is holded by a single `Transition`.
203+
- `Transition.destinations` removed in favor of `Transition.target` (following SCXML convention).
204+
Now each transition only points to a unique target. Each `source->target` pair is holded by a
205+
single `Transition`.
206206

207207
## Deprecated features in 1.0
208208

docs/transitions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ When an {ref}`event` is sent to a stamemachine:
102102

103103
1. Uses the current {ref}`state` to check for available transitions.
104104
1. For each possible transition, it checks for those that matches the received {ref}`event`.
105-
1. The destination state, if the transition succeeds, is determined by a transisition
105+
1. The target state, if the transition succeeds, is determined by a transisition
106106
that an event matches and;
107107
1. All {ref}`validators-and-guards`, including {ref}`actions`
108108
atached to the `on_<event>` and `before_<event>` callbacks.
@@ -119,18 +119,18 @@ By direct calling the event:
119119
>>> machine.cycle()
120120
'Running cycle from green to yellow'
121121

122-
>>> machine.current_state.identifier
122+
>>> machine.current_state.id
123123
'yellow'
124124

125125
```
126126

127127
In a running (interpreted) machine, events are `sent`:
128128

129129
```py
130-
>>> machine.run("cycle")
130+
>>> machine.send("cycle")
131131
'Running cycle from yellow to red'
132132

133-
>>> machine.current_state.identifier
133+
>>> machine.current_state.id
134134
'red'
135135

136136
```
@@ -151,13 +151,13 @@ This action is executed before the transition associated with `cycle` event is a
151151
can also raise an exception at this point to stop a transition to occur.
152152

153153
```py
154-
>>> machine.current_state.identifier
154+
>>> machine.current_state.id
155155
'red'
156156

157157
>>> machine.cycle()
158158
'Running cycle from red to green'
159159

160-
>>> machine.current_state.identifier
160+
>>> machine.current_state.id
161161
'green'
162162

163163
```

0 commit comments

Comments
 (0)