Skip to content

Commit 13ab6e0

Browse files
committed
refac: Split the SCXML parser into schema definition, parser and actions for executable content
1 parent 4b863a0 commit 13ab6e0

25 files changed

Lines changed: 1027 additions & 751 deletions

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
#----------------------------------------------
4747
- name: Test with pytest
4848
run: |
49-
uv run pytest --cov-report=xml:coverage.xml
49+
uv run pytest -n auto --cov-report=xml:coverage.xml
5050
uv run coverage xml
5151
#----------------------------------------------
5252
# upload coverage

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: Test
3535
run: |
36-
uv run pytest
36+
uv run pytest -n auto
3737
3838
- name: Build
3939
run: |

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
pass_filenames: false
2828
- id: pytest
2929
name: Pytest
30-
entry: uv run pytest
30+
entry: uv run pytest -n auto
3131
types: [python]
3232
language: system
3333
pass_filenames: false

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dev = [
5252
"furo >=2024.5.6",
5353
"sphinx-copybutton >=0.5.2",
5454
"pdbr>=0.8.9",
55+
"pytest-xdist>=3.6.1",
5556
]
5657

5758
[build-system]
@@ -63,6 +64,7 @@ packages = ["statemachine/"]
6364

6465
[tool.pytest.ini_options]
6566
addopts = [
67+
"-s",
6668
"--ignore=docs/conf.py",
6769
"--ignore=docs/auto_examples/",
6870
"--ignore=docs/_build/",
@@ -85,6 +87,9 @@ markers = [
8587
]
8688
python_files = ["tests.py", "test_*.py", "*_tests.py"]
8789
xfail_strict = true
90+
log_cli = true
91+
log_cli_level = "DEBUG"
92+
asyncio_default_fixture_loop_scope = "module"
8893

8994
[tool.coverage.run]
9095
branch = true

statemachine/io/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class TransitionDict(TypedDict, total=False):
1818
target: str
19-
event: str
19+
event: str | None
2020
internal: bool
2121
validators: bool
2222
cond: CallbacksType
@@ -26,6 +26,9 @@ class TransitionDict(TypedDict, total=False):
2626
after: CallbacksType
2727

2828

29+
TransitionsDict = Dict[str | None, List[TransitionDict]]
30+
31+
2932
class StateDict(TypedDict, total=False):
3033
name: str
3134
value: Any
@@ -36,7 +39,7 @@ class StateDict(TypedDict, total=False):
3639

3740

3841
class StateWithTransitionsDict(StateDict, total=False):
39-
on: Dict[str, List[TransitionDict]]
42+
on: TransitionsDict
4043

4144

4245
StateOptions = StateDict | StateWithTransitionsDict
@@ -75,19 +78,20 @@ def create_machine_class_from_definition(
7578
events: Dict[str, TransitionList] = {}
7679
for state_id, state_events in events_definitions.items():
7780
for event_name, transitions_data in state_events.items():
78-
for trantion_data in transitions_data:
81+
for transition_data in transitions_data:
7982
source = states_instances[state_id]
8083

81-
target = states_instances[trantion_data["target"]]
84+
target = states_instances[transition_data["target"]]
8285

86+
# TODO: Join `trantion_data.event` with `event_name`
8387
transition = source.to(
8488
target,
8589
event=event_name,
86-
cond=trantion_data.get("cond"),
87-
unless=trantion_data.get("unless"),
88-
on=trantion_data.get("on"),
89-
before=trantion_data.get("before"),
90-
after=trantion_data.get("after"),
90+
cond=transition_data.get("cond"),
91+
unless=transition_data.get("unless"),
92+
on=transition_data.get("on"),
93+
before=transition_data.get("before"),
94+
after=transition_data.get("after"),
9195
)
9296

9397
if event_name in events:

0 commit comments

Comments
 (0)