Skip to content

Commit d7738e9

Browse files
committed
black
1 parent 762b1a9 commit d7738e9

21 files changed

Lines changed: 137 additions & 110 deletions

docs/auto_examples/all_actions_machine.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
},
8181
"outputs": [],
8282
"source": [
83-
"assert spy.call_args_list == [\n mock.call(\"on_enter_state\"),\n mock.call(\"enter_initial_decor\"),\n mock.call(\"on_enter_initial\"),\n\n mock.call(\"validation_1\"),\n mock.call(\"validation_2\"),\n\n mock.call(\"condition_1\"),\n mock.call(\"condition_2\"),\n\n mock.call(\"unless_1\"),\n mock.call(\"unless_2\"),\n\n mock.call(\"before_transition\"),\n mock.call(\"before_go_inline_1\"),\n mock.call(\"before_go_inline_2\"),\n mock.call(\"before_go_decor\"),\n mock.call(\"before_go\"),\n\n mock.call(\"on_exit_state\"),\n mock.call(\"exit_initial_decor\"),\n mock.call(\"on_exit_initial\"),\n\n mock.call(\"on_transition\"),\n mock.call(\"on_inline_1\"),\n mock.call(\"on_inline_2\"),\n mock.call(\"go_on_decor\"),\n mock.call(\"on_go\"),\n\n mock.call(\"on_enter_state\"),\n mock.call(\"on_enter_final\"),\n\n mock.call(\"after_go_inline_1\"),\n mock.call(\"after_go_inline_2\"),\n mock.call(\"after_go_decor\"),\n mock.call(\"after_go\"),\n mock.call(\"after_transition\"),\n]"
83+
"assert spy.call_args_list == [\n mock.call(\"on_enter_state\"),\n mock.call(\"enter_initial_decor\"),\n mock.call(\"on_enter_initial\"),\n mock.call(\"validation_1\"),\n mock.call(\"validation_2\"),\n mock.call(\"condition_1\"),\n mock.call(\"condition_2\"),\n mock.call(\"unless_1\"),\n mock.call(\"unless_2\"),\n mock.call(\"before_transition\"),\n mock.call(\"before_go_inline_1\"),\n mock.call(\"before_go_inline_2\"),\n mock.call(\"before_go_decor\"),\n mock.call(\"before_go\"),\n mock.call(\"on_exit_state\"),\n mock.call(\"exit_initial_decor\"),\n mock.call(\"on_exit_initial\"),\n mock.call(\"on_transition\"),\n mock.call(\"on_inline_1\"),\n mock.call(\"on_inline_2\"),\n mock.call(\"go_on_decor\"),\n mock.call(\"on_go\"),\n mock.call(\"on_enter_state\"),\n mock.call(\"on_enter_final\"),\n mock.call(\"after_go_inline_1\"),\n mock.call(\"after_go_inline_2\"),\n mock.call(\"after_go_decor\"),\n mock.call(\"after_go\"),\n mock.call(\"after_transition\"),\n]"
8484
]
8585
}
8686
],

docs/auto_examples/all_actions_machine.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,35 +172,27 @@ def on_exit_final(self):
172172
mock.call("on_enter_state"),
173173
mock.call("enter_initial_decor"),
174174
mock.call("on_enter_initial"),
175-
176175
mock.call("validation_1"),
177176
mock.call("validation_2"),
178-
179177
mock.call("condition_1"),
180178
mock.call("condition_2"),
181-
182179
mock.call("unless_1"),
183180
mock.call("unless_2"),
184-
185181
mock.call("before_transition"),
186182
mock.call("before_go_inline_1"),
187183
mock.call("before_go_inline_2"),
188184
mock.call("before_go_decor"),
189185
mock.call("before_go"),
190-
191186
mock.call("on_exit_state"),
192187
mock.call("exit_initial_decor"),
193188
mock.call("on_exit_initial"),
194-
195189
mock.call("on_transition"),
196190
mock.call("on_inline_1"),
197191
mock.call("on_inline_2"),
198192
mock.call("go_on_decor"),
199193
mock.call("on_go"),
200-
201194
mock.call("on_enter_state"),
202195
mock.call("on_enter_final"),
203-
204196
mock.call("after_go_inline_1"),
205197
mock.call("after_go_inline_2"),
206198
mock.call("after_go_decor"),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2ecf205507cf53ed84b6bc34e9f6fffb
1+
a67dd8e6360bbc7795e9159cc1af0520

docs/auto_examples/all_actions_machine.rst

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Only before/on actions have their result collected.
229229
230230
Checking the method resolution order
231231

232-
.. GENERATED FROM PYTHON SOURCE LINES 170-210
232+
.. GENERATED FROM PYTHON SOURCE LINES 170-202
233233
234234
.. code-block:: default
235235
@@ -238,35 +238,27 @@ Checking the method resolution order
238238
mock.call("on_enter_state"),
239239
mock.call("enter_initial_decor"),
240240
mock.call("on_enter_initial"),
241-
242241
mock.call("validation_1"),
243242
mock.call("validation_2"),
244-
245243
mock.call("condition_1"),
246244
mock.call("condition_2"),
247-
248245
mock.call("unless_1"),
249246
mock.call("unless_2"),
250-
251247
mock.call("before_transition"),
252248
mock.call("before_go_inline_1"),
253249
mock.call("before_go_inline_2"),
254250
mock.call("before_go_decor"),
255251
mock.call("before_go"),
256-
257252
mock.call("on_exit_state"),
258253
mock.call("exit_initial_decor"),
259254
mock.call("on_exit_initial"),
260-
261255
mock.call("on_transition"),
262256
mock.call("on_inline_1"),
263257
mock.call("on_inline_2"),
264258
mock.call("go_on_decor"),
265259
mock.call("on_go"),
266-
267260
mock.call("on_enter_state"),
268261
mock.call("on_enter_final"),
269-
270262
mock.call("after_go_inline_1"),
271263
mock.call("after_go_inline_2"),
272264
mock.call("after_go_decor"),

docs/auto_examples/guess_the_number_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-
"import random\nfrom statemachine import StateMachine, State\n\n\nclass GuessTheNumberMachine(StateMachine):\n\n start = State(\"Start\", initial=True)\n low = State(\"Low\")\n high = State(\"High\")\n won = State(\"Won\", final=True)\n lose = State(\"Lose\", final=True)\n\n guess = (\n lose.from_(low, high, cond=\"max_guesses_reached\")\n | won.from_(low, high, cond=\"guess_is_equal\")\n | low.from_(low, high, start, cond=\"guess_is_lower\")\n | high.from_(low, high, start, cond=\"guess_is_higher\")\n )\n\n def __init__(self, max_attempts=5, lower=1, higher=5, seed=42):\n self.max_attempts = max_attempts\n self.lower = lower\n self.higher = higher\n self.guesses = 0\n\n # lets play a not so random game, or our tests will be crazy\n random.seed(seed)\n self.number = random.randint(self.lower, self.higher)\n super(GuessTheNumberMachine, self).__init__()\n\n def max_guesses_reached(self):\n return self.guesses >= self.max_attempts\n\n def before_guess(self, number):\n self.guesses += 1\n print(\"You guess is {}...\".format(number))\n\n def guess_is_lower(self, number):\n return number < self.number\n\n def guess_is_higher(self, number):\n return number > self.number\n\n def guess_is_equal(self, number):\n return self.number == number\n\n def on_enter_start(self):\n print(\"(psss.. don't tell anyone the number is {})\".format(self.number))\n print(\"I'm thinking of a number between {} and {}. Can you guess what it is?\".format(\n self.lower, self.higher\n ))\n\n def on_enter_low(self):\n print(\"Too low. Try again.\")\n\n def on_enter_high(self):\n print(\"Too high. Try again.\")\n\n def on_enter_won(self):\n print(\"Congratulations, you guessed the number in {} guesses!\".format(self.guesses))\n\n def on_enter_lose(self):\n print(\"Oh, no! You've spent all your {} attempts!\".format(self.guesses))"
29+
"import random\nfrom statemachine import StateMachine, State\n\n\nclass GuessTheNumberMachine(StateMachine):\n\n start = State(\"Start\", initial=True)\n low = State(\"Low\")\n high = State(\"High\")\n won = State(\"Won\", final=True)\n lose = State(\"Lose\", final=True)\n\n guess = (\n lose.from_(low, high, cond=\"max_guesses_reached\")\n | won.from_(low, high, cond=\"guess_is_equal\")\n | low.from_(low, high, start, cond=\"guess_is_lower\")\n | high.from_(low, high, start, cond=\"guess_is_higher\")\n )\n\n def __init__(self, max_attempts=5, lower=1, higher=5, seed=42):\n self.max_attempts = max_attempts\n self.lower = lower\n self.higher = higher\n self.guesses = 0\n\n # lets play a not so random game, or our tests will be crazy\n random.seed(seed)\n self.number = random.randint(self.lower, self.higher)\n super(GuessTheNumberMachine, self).__init__()\n\n def max_guesses_reached(self):\n return self.guesses >= self.max_attempts\n\n def before_guess(self, number):\n self.guesses += 1\n print(\"You guess is {}...\".format(number))\n\n def guess_is_lower(self, number):\n return number < self.number\n\n def guess_is_higher(self, number):\n return number > self.number\n\n def guess_is_equal(self, number):\n return self.number == number\n\n def on_enter_start(self):\n print(\"(psss.. don't tell anyone the number is {})\".format(self.number))\n print(\n \"I'm thinking of a number between {} and {}. Can you guess what it is?\".format(\n self.lower, self.higher\n )\n )\n\n def on_enter_low(self):\n print(\"Too low. Try again.\")\n\n def on_enter_high(self):\n print(\"Too high. Try again.\")\n\n def on_enter_won(self):\n print(\n \"Congratulations, you guessed the number in {} guesses!\".format(\n self.guesses\n )\n )\n\n def on_enter_lose(self):\n print(\"Oh, no! You've spent all your {} attempts!\".format(self.guesses))"
3030
]
3131
},
3232
{

docs/auto_examples/guess_the_number_machine.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ def guess_is_equal(self, number):
5656

5757
def on_enter_start(self):
5858
print("(psss.. don't tell anyone the number is {})".format(self.number))
59-
print("I'm thinking of a number between {} and {}. Can you guess what it is?".format(
60-
self.lower, self.higher
61-
))
59+
print(
60+
"I'm thinking of a number between {} and {}. Can you guess what it is?".format(
61+
self.lower, self.higher
62+
)
63+
)
6264

6365
def on_enter_low(self):
6466
print("Too low. Try again.")
@@ -67,7 +69,11 @@ def on_enter_high(self):
6769
print("Too high. Try again.")
6870

6971
def on_enter_won(self):
70-
print("Congratulations, you guessed the number in {} guesses!".format(self.guesses))
72+
print(
73+
"Congratulations, you guessed the number in {} guesses!".format(
74+
self.guesses
75+
)
76+
)
7177

7278
def on_enter_lose(self):
7379
print("Oh, no! You've spent all your {} attempts!".format(self.guesses))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a2ada476f8006636e7e61d01c97b6279
1+
4f09d706ccb016f2ae496d4f3cbbdb8b

docs/auto_examples/guess_the_number_machine.rst

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ An StateMachine for the well know game.
2525

2626
Well leave the machine imagine a number and also play the game. Why not?
2727

28-
.. GENERATED FROM PYTHON SOURCE LINES 10-76
28+
.. GENERATED FROM PYTHON SOURCE LINES 10-82
2929
3030
.. code-block:: default
3131
@@ -78,9 +78,11 @@ Well leave the machine imagine a number and also play the game. Why not?
7878
7979
def on_enter_start(self):
8080
print("(psss.. don't tell anyone the number is {})".format(self.number))
81-
print("I'm thinking of a number between {} and {}. Can you guess what it is?".format(
82-
self.lower, self.higher
83-
))
81+
print(
82+
"I'm thinking of a number between {} and {}. Can you guess what it is?".format(
83+
self.lower, self.higher
84+
)
85+
)
8486
8587
def on_enter_low(self):
8688
print("Too low. Try again.")
@@ -89,7 +91,11 @@ Well leave the machine imagine a number and also play the game. Why not?
8991
print("Too high. Try again.")
9092
9193
def on_enter_won(self):
92-
print("Congratulations, you guessed the number in {} guesses!".format(self.guesses))
94+
print(
95+
"Congratulations, you guessed the number in {} guesses!".format(
96+
self.guesses
97+
)
98+
)
9399
94100
def on_enter_lose(self):
95101
print("Oh, no! You've spent all your {} attempts!".format(self.guesses))
@@ -107,13 +113,13 @@ Well leave the machine imagine a number and also play the game. Why not?
107113

108114

109115

110-
.. GENERATED FROM PYTHON SOURCE LINES 77-80
116+
.. GENERATED FROM PYTHON SOURCE LINES 83-86
111117
112118
Playing
113119
-------
114120

115121

116-
.. GENERATED FROM PYTHON SOURCE LINES 80-83
122+
.. GENERATED FROM PYTHON SOURCE LINES 86-89
117123
118124
.. code-block:: default
119125
@@ -134,7 +140,7 @@ Playing
134140
135141
136142
137-
.. GENERATED FROM PYTHON SOURCE LINES 84-87
143+
.. GENERATED FROM PYTHON SOURCE LINES 90-93
138144
139145
.. code-block:: default
140146
@@ -155,7 +161,7 @@ Playing
155161
156162
157163
158-
.. GENERATED FROM PYTHON SOURCE LINES 88-91
164+
.. GENERATED FROM PYTHON SOURCE LINES 94-97
159165
160166
.. code-block:: default
161167
@@ -318,7 +324,7 @@ Playing
318324
<br />
319325
<br />
320326

321-
.. GENERATED FROM PYTHON SOURCE LINES 92-95
327+
.. GENERATED FROM PYTHON SOURCE LINES 98-101
322328
323329
.. code-block:: default
324330
@@ -339,7 +345,7 @@ Playing
339345
340346
341347
342-
.. GENERATED FROM PYTHON SOURCE LINES 96-102
348+
.. GENERATED FROM PYTHON SOURCE LINES 102-108
343349
344350
.. code-block:: default
345351
@@ -512,7 +518,7 @@ Playing
512518
<br />
513519
<br />
514520

515-
.. GENERATED FROM PYTHON SOURCE LINES 105-108
521+
.. GENERATED FROM PYTHON SOURCE LINES 111-114
516522
517523
.. code-block:: default
518524
@@ -533,7 +539,7 @@ Playing
533539
534540
535541
536-
.. GENERATED FROM PYTHON SOURCE LINES 109-112
542+
.. GENERATED FROM PYTHON SOURCE LINES 115-118
537543
538544
.. code-block:: default
539545
@@ -554,7 +560,7 @@ Playing
554560
555561
556562
557-
.. GENERATED FROM PYTHON SOURCE LINES 113-116
563+
.. GENERATED FROM PYTHON SOURCE LINES 119-122
558564
559565
.. code-block:: default
560566
@@ -717,7 +723,7 @@ Playing
717723
<br />
718724
<br />
719725

720-
.. GENERATED FROM PYTHON SOURCE LINES 117-122
726+
.. GENERATED FROM PYTHON SOURCE LINES 123-128
721727
722728
.. code-block:: default
723729

docs/conf.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
html_static_path = ["_static"]
157157

158158
html_css_files = [
159-
'custom_machine.css',
159+
"custom_machine.css",
160160
]
161161

162162
# If not '', a 'Last updated on:' timestamp is inserted at every page
@@ -345,16 +345,16 @@
345345

346346
# Sphinx Galery
347347
sphinx_gallery_conf = {
348-
'examples_dirs': ['../tests/examples',], # path to your example scripts
349-
'gallery_dirs': 'auto_examples', # path to where to save gallery generated output
350-
'capture_repr': ('_repr_html_', '__repr__'),
351-
'filename_pattern': r'/.*\_machine.py',
352-
'download_all_examples': False,
348+
"examples_dirs": [
349+
"../tests/examples",
350+
], # path to your example scripts
351+
"gallery_dirs": "auto_examples", # path to where to save gallery generated output
352+
"capture_repr": ("_repr_html_", "__repr__"),
353+
"filename_pattern": r"/.*\_machine.py",
354+
"download_all_examples": False,
353355
"show_signature": False,
354356
"min_reported_time": 9999,
355-
356-
'thumbnail_size': (400, 280),
357-
'image_scrapers': ('matplotlib', MachineScraper()),
358-
357+
"thumbnail_size": (400, 280),
358+
"image_scrapers": ("matplotlib", MachineScraper()),
359359
# "first_notebook_cell": "",
360360
}

statemachine/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def add_from_attributes(cls, attrs):
104104
cls.add_state(key, value)
105105
elif isinstance(value, (Transition, TransitionList)):
106106
cls.add_event(key, value)
107-
elif getattr(value, '_callbacks_to_update', None):
107+
elif getattr(value, "_callbacks_to_update", None):
108108
cls._add_unbounded_callback(key, value)
109109

110110
def _add_unbounded_callback(cls, attr_name, func):

0 commit comments

Comments
 (0)