Skip to content

Commit d5006b5

Browse files
committed
Merge branch 'release/2.5.0'
2 parents 9434716 + 2093cf1 commit d5006b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3352
-2591
lines changed

.github/workflows/python-package.yml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,61 +15,49 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.1"]
18+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
- run: git fetch origin develop
2323
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v3
24+
uses: actions/setup-python@v5
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727
- name: Setup Graphviz
28-
uses: ts-graphviz/setup-graphviz@v1
29-
- name: Install Poetry
30-
uses: snok/install-poetry@v1
28+
uses: ts-graphviz/setup-graphviz@v2
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v3
3131
with:
32-
version: 1.5.1
33-
virtualenvs-create: true
34-
virtualenvs-in-project: true
35-
installer-parallel: true
36-
- name: Load cached venv
37-
id: cached-poetry-dependencies
38-
uses: actions/cache@v3
39-
with:
40-
path: .venv
41-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
42-
- name: Install dependencies
43-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
44-
run: poetry install --no-interaction --no-root --all-extras
32+
enable-cache: true
33+
cache-suffix: "python${{ matrix.python-version }}"
34+
- name: Install the project
35+
run: uv sync --all-extras --dev
4536
- name: Install old pydot for 3.7 only
4637
if: matrix.python-version == 3.7
4738
run: |
48-
source .venv/bin/activate
49-
pip install pydot==2.0.0
39+
uv pip install pydot==2.0.0
5040
#----------------------------------------------
5141
# run ruff
5242
#----------------------------------------------
5343
- name: Linter with ruff
54-
if: matrix.python-version == 3.12
44+
if: matrix.python-version == 3.13
5545
run: |
56-
source .venv/bin/activate
57-
ruff check .
58-
ruff format --check .
46+
uv run ruff check .
47+
uv run ruff format --check .
5948
#----------------------------------------------
6049
# run pytest
6150
#----------------------------------------------
6251
- name: Test with pytest
6352
run: |
64-
source .venv/bin/activate
65-
pytest --cov-report=xml:coverage.xml
66-
coverage xml
53+
uv run pytest --cov-report=xml:coverage.xml
54+
uv run coverage xml
6755
#----------------------------------------------
6856
# upload coverage
6957
#----------------------------------------------
7058
- name: Upload coverage to Codecov
7159
uses: codecov/codecov-action@v4
72-
if: matrix.python-version == 3.12
60+
if: matrix.python-version == 3.13
7361
with:
7462
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
7563
directory: .

.github/workflows/release.yml

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,65 @@ on:
44
name: release
55

66
jobs:
7-
pypi-publish:
8-
name: upload release to PyPI
7+
release-build:
8+
name: Build release artifacts
99
runs-on: ubuntu-latest
10-
strategy:
11-
fail-fast: false
12-
matrix:
13-
python-version: ["3.12"]
1410

15-
# Specifying a GitHub environment is optional, but strongly encouraged
11+
permissions:
12+
id-token: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- run: git fetch origin develop
17+
18+
- name: Setup Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.13'
22+
23+
- name: Setup Graphviz
24+
uses: ts-graphviz/setup-graphviz@v2
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v3
28+
with:
29+
enable-cache: true
30+
31+
- name: Install the project
32+
run: uv sync --all-extras --dev
33+
34+
- name: Test
35+
run: |
36+
uv run pytest
37+
38+
- name: Build
39+
run: |
40+
uv build
41+
42+
- name: Upload dists
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: release-dists
46+
path: dist/
47+
48+
49+
pypi-publish:
50+
# by a dedicated job to publish we avoid the risk of
51+
# running code with access to PyPI credentials
52+
name: Upload release to PyPI
53+
runs-on: ubuntu-latest
54+
needs:
55+
- release-build
1656
environment: release
1757
permissions:
18-
# IMPORTANT: this permission is mandatory for trusted publishing
1958
id-token: write
59+
2060
steps:
21-
- uses: actions/checkout@v3
22-
- run: git fetch origin develop
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v4
25-
with:
26-
python-version: ${{ matrix.python-version }}
27-
- name: Setup Graphviz
28-
uses: ts-graphviz/setup-graphviz@v1
29-
- name: Install Poetry
30-
uses: snok/install-poetry@v1
31-
with:
32-
version: 1.5.1
33-
virtualenvs-create: true
34-
virtualenvs-in-project: true
35-
installer-parallel: true
36-
- name: Load cached venv
37-
id: cached-poetry-dependencies
38-
uses: actions/cache@v3
39-
with:
40-
path: .venv
41-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
42-
- name: Install dependencies
43-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
44-
run: poetry install --no-interaction --no-root --all-extras
45-
- name: Test with pytest
46-
run: |
47-
source .venv/bin/activate
48-
pytest
49-
- name: Poetry build
50-
run: |
51-
source .venv/bin/activate
52-
poetry build
53-
- name: Publish package distributions to PyPI
54-
uses: pypa/gh-action-pypi-publish@release/v1
61+
- name: Retrieve release distributions
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: release-dists
65+
path: dist/
66+
67+
- name: Publish package distributions to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
@@ -9,7 +9,7 @@ repos:
99
exclude: docs/auto_examples
1010
- repo: https://github.com/charliermarsh/ruff-pre-commit
1111
# Ruff version.
12-
rev: v0.3.7
12+
rev: v0.8.1
1313
hooks:
1414
# Run the linter.
1515
- id: ruff
@@ -21,13 +21,13 @@ repos:
2121
hooks:
2222
- id: mypy
2323
name: Mypy
24-
entry: poetry run mypy --namespace-packages --explicit-package-bases statemachine/ tests/
24+
entry: uv run mypy --namespace-packages --explicit-package-bases statemachine/ tests/
2525
types: [python]
2626
language: system
2727
pass_filenames: false
2828
- id: pytest
2929
name: Pytest
30-
entry: poetry run pytest
30+
entry: uv run pytest
3131
types: [python]
3232
language: system
3333
pass_filenames: false

.readthedocs.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,18 @@
55
# Required
66
version: 2
77

8-
# Set the version of Python and other tools you might need
98
build:
10-
os: ubuntu-22.04
9+
os: "ubuntu-22.04"
1110
tools:
1211
python: "3.12"
1312
apt_packages:
1413
- graphviz
1514
jobs:
1615
post_create_environment:
17-
# Install poetry
18-
# https://python-poetry.org/docs/#installing-manually
19-
- python -m pip install poetry
20-
# Tell poetry to not use a virtual environment
21-
- poetry config virtualenvs.create false
22-
post_install:
23-
# Install dependencies with 'docs' dependency group
24-
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
25-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --extras diagrams --with docs
16+
- asdf plugin add uv
17+
- asdf install uv latest
18+
- asdf global uv latest
19+
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --all-extras --frozen
2620

2721
# Build documentation in the docs/ directory with Sphinx
2822
sphinx:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,27 @@ Easily iterate over all states:
168168

169169
```py
170170
>>> [s.id for s in sm.states]
171-
['green', 'red', 'yellow']
171+
['green', 'yellow', 'red']
172172

173173
```
174174

175175
Or over events:
176176

177177
```py
178-
>>> [t.name for t in sm.events]
178+
>>> [t.id for t in sm.events]
179179
['cycle']
180180

181181
```
182182

183-
Call an event by its name:
183+
Call an event by its id:
184184

185185
```py
186186
>>> sm.cycle()
187187
Don't move.
188188
'Running cycle from yellow to red'
189189

190190
```
191-
Or send an event with the event name:
191+
Or send an event with the event id:
192192

193193
```py
194194
>>> sm.send('cycle')

docs/async.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ Engines are internal and are activated automatically by inspecting the registere
4747
4848
```
4949

50+
Outer scope
51+
: The context in which the state machine **instance** is created.
52+
53+
Async callbacks?
54+
: Indicates whether the state machine has declared asynchronous callbacks or conditions.
55+
56+
Engine
57+
: The engine that will be utilized.
58+
59+
Creates internal loop
60+
: Specifies whether the state machine initiates a new event loop if no [asyncio loop is running](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop).
61+
62+
Reuses external loop
63+
: Indicates whether the state machine reuses an existing [asyncio loop](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop) if one is already running.
64+
65+
66+
5067
```{note}
5168
All handlers will run on the same thread they are called. Therefore, mixing synchronous and asynchronous code is not recommended unless you are confident in your implementation.
5269
```

docs/contributing.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Ready to contribute? Here's how to set up `python-statemachine` for local develo
8787

8888
1. Install dependencies.
8989
1. [graphviz](https://graphviz.org/download/#linux)
90-
1. [poetry](https://python-poetry.org/docs/#installation)
90+
1. [uv](https://docs.astral.sh/uv/getting-started/installation/)
9191

9292
1. Fork the `python-statemachine` repository on GitHub.
9393

@@ -96,31 +96,29 @@ Ready to contribute? Here's how to set up `python-statemachine` for local develo
9696
git clone https://github.com/YOUR-USERNAME/python-statemachine.git.
9797

9898

99-
1. Run `poetry install` once to install all the dependencies and create a virtual environment::
99+
1. Run `uv sync` once to install all the development dependencies and create a virtual environment::
100100

101-
poetry install --all-extras
101+
uv sync --all-extras
102102

103-
1. Run `poetry shell` to enter the provided virtual
104-
105-
1. Install the pre-commit validations:
103+
2. Install the pre-commit validations:
106104

107105
pre-commit install
108106

109-
1. Create a branch for local development:
107+
3. Create a branch for local development:
110108

111109
git checkout -b <name-of-your-bugfix-or-feature>
112110

113-
1. Make changes to the code.
111+
4. Make changes to the code.
114112

115-
1. Run tests to ensure they pass by running:
113+
5. Run tests to ensure they pass by running:
116114

117-
poetry run pytest
115+
uv run pytest
118116

119-
1. Update the documentation as needed.
117+
6. Update the documentation as needed.
120118

121119
Build the documentation:
122120

123-
poetry run sphinx-build docs docs/_build/html
121+
uv run sphinx-build docs docs/_build/html
124122

125123

126124
Now you can serve the local documentation using a webserver, like the built-in included
@@ -133,7 +131,7 @@ Ready to contribute? Here's how to set up `python-statemachine` for local develo
133131
If you're specially writting documentation, I strongly recommend using `sphinx-autobuild`
134132
as it improves the workflow watching for file changes and with live reloading:
135133

136-
poetry run sphinx-autobuild docs docs/_build/html --re-ignore "auto_examples/.*"
134+
uv run sphinx-autobuild docs docs/_build/html --re-ignore "auto_examples/.*"
137135

138136
Sometimes you need a full fresh of the files being build for docs, you can safely remove
139137
all automatically generated files to get a clean state by running:

0 commit comments

Comments
 (0)