-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
1,894 additions
and
1,313 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
on: | ||
push: | ||
tags: [ 'v?*.*.*' ] | ||
name: release | ||
|
||
jobs: | ||
pypi-publish: | ||
name: upload release to PyPI | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.12"] | ||
|
||
# Specifying a GitHub environment is optional, but strongly encouraged | ||
environment: release | ||
permissions: | ||
# IMPORTANT: this permission is mandatory for trusted publishing | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: git fetch origin develop | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.5.1 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install dependencies | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: poetry install --no-interaction --no-root | ||
- name: Test with pytest | ||
run: | | ||
source .venv/bin/activate | ||
pytest | ||
- name: Poetry build | ||
run: | | ||
source .venv/bin/activate | ||
poetry build | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# StateMachine 2.2.0 | ||
|
||
*May 6, 2024* | ||
|
||
## What's new in 2.2.0 | ||
|
||
In this release, we conducted a general cleanup and refactoring across various modules to enhance code readability and maintainability. We improved exception handling and reduced code redundancy. | ||
|
||
As a result, we achieved a **~2.2x** faster setup in our performance tests and significantly simplified the callback machinery. | ||
|
||
|
||
### Check of unreachable and non-final states | ||
|
||
We included one more state machine definition validation for non-final states. | ||
|
||
We already check if any states are unreachable from the initial state, if not, an `InvalidDefinition` exception is thrown. | ||
|
||
```py | ||
>>> from statemachine import StateMachine, State | ||
|
||
>>> class TrafficLightMachine(StateMachine): | ||
... "A workflow machine" | ||
... red = State('Red', initial=True, value=1) | ||
... green = State('Green', value=2) | ||
... orange = State('Orange', value=3) | ||
... hazard = State('Hazard', value=4) | ||
... | ||
... cycle = red.to(green) | green.to(orange) | orange.to(red) | ||
... blink = hazard.to.itself() | ||
Traceback (most recent call last): | ||
... | ||
InvalidDefinition: There are unreachable states. The statemachine graph should have a single component. Disconnected states: ['hazard'] | ||
``` | ||
|
||
From this release, `StateMachine` will also check that all non-final states have an outgoing transition, | ||
and warn you if any states would result in the statemachine becoming trapped in a non-final state with no further transitions possible. | ||
|
||
```{note} | ||
This will currently issue a warning, but can be turned into an exception by setting `strict_states=True` on the class. | ||
``` | ||
|
||
```py | ||
>>> from statemachine import StateMachine, State | ||
|
||
>>> class TrafficLightMachine(StateMachine, strict_states=True): | ||
... "A workflow machine" | ||
... red = State('Red', initial=True, value=1) | ||
... green = State('Green', value=2) | ||
... orange = State('Orange', value=3) | ||
... hazard = State('Hazard', value=4) | ||
... | ||
... cycle = red.to(green) | green.to(orange) | orange.to(red) | ||
... fault = red.to(hazard) | green.to(hazard) | orange.to(hazard) | ||
Traceback (most recent call last): | ||
... | ||
InvalidDefinition: All non-final states should have at least one outgoing transition. These states have no outgoing transition: ['hazard'] | ||
``` | ||
|
||
```{warning} | ||
`strict_states=True` will become the default behaviour in the next major release. | ||
``` | ||
|
||
See {ref}`State Transitions`. | ||
|
||
|
||
## Bugfixes in 2.2.0 | ||
|
||
- Fixes [#424](https://github.com/fgmacedo/python-statemachine/issues/424) allowing `deepcopy` of state machines. | ||
- **Dispatch Mechanism**: Resolved issues in the dispatch mechanism in `statemachine/dispatcher.py` that affected the reliability | ||
of event handling across different states. This fix ensures consistent behavior when events are dispatched in complex state | ||
machine configurations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.