Skip to content

Commit 314a90e

Browse files
committed
Migrate from Poetry to uv
- Convert pyproject.toml from [tool.poetry] to PEP 621 [project] - Move dev dependencies to [dependency-groups] - Switch build backend from poetry-core to hatchling - Replace poetry.lock with uv.lock - Update GitHub workflows to install uv and run uv sync/uv run - Switch release workflow to trusted publishing (OIDC) - Update pre-commit config to use uv run - Update README to reference uv - Switch renovate manager from poetry to pep621 - Fix lint issues exposed by target-version=py313 inferred from project.requires-python (typing.Self, datetime.UTC, asyncio.TimeoutError, PEP 695 generic syntax)
1 parent 96b0b6c commit 314a90e

13 files changed

Lines changed: 1877 additions & 2727 deletions

File tree

β€Ž.github/renovate.jsonβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
"commitMessagePrefix": "⬆️",
1212
"packageRules": [
1313
{
14-
"matchManagers": ["poetry"],
14+
"matchManagers": ["pep621"],
1515
"addLabels": ["python"]
1616
},
1717
{
18-
"matchManagers": ["poetry"],
18+
"matchManagers": ["pep621"],
1919
"matchDepTypes": ["dev"],
2020
"rangeStrategy": "pin"
2121
},
2222
{
23-
"matchManagers": ["poetry"],
23+
"matchManagers": ["pep621"],
2424
"matchUpdateTypes": ["minor", "patch"],
2525
"automerge": true
2626
},

β€Ž.github/workflows/linting.yamlβ€Ž

Lines changed: 80 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,57 @@ jobs:
1919
steps:
2020
- name: ‡️ Check out code from GitHub
2121
uses: actions/checkout@v6.0.2
22-
- name: πŸ— Set up Poetry
23-
run: pipx install poetry
2422
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
2523
id: python
2624
uses: actions/setup-python@v6.2.0
2725
with:
2826
python-version: ${{ env.DEFAULT_PYTHON }}
29-
cache: "poetry"
30-
- name: πŸ— Install workflow dependencies
27+
- name: πŸ“¦ Cache uv
28+
uses: actions/cache@v5
29+
with:
30+
path: |
31+
~/.cache/uv
32+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-uv-
35+
- name: πŸ— Install uv
3136
run: |
32-
poetry config virtualenvs.create true
33-
poetry config virtualenvs.in-project true
37+
curl -LsSf https://astral.sh/uv/install.sh | sh
38+
echo "$HOME/.local/bin" >> $GITHUB_PATH
3439
- name: πŸ— Install Python dependencies
35-
run: poetry install --no-interaction
40+
run: uv sync --all-groups
3641
- name: πŸš€ Check code for common misspellings
37-
run: poetry run prek run codespell --all-files
42+
run: uv run prek run codespell --all-files
3843

3944
ruff:
4045
name: Ruff
4146
runs-on: ubuntu-latest
4247
steps:
4348
- name: ‡️ Check out code from GitHub
4449
uses: actions/checkout@v6.0.2
45-
- name: πŸ— Set up Poetry
46-
run: pipx install poetry
4750
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
4851
id: python
4952
uses: actions/setup-python@v6.2.0
5053
with:
5154
python-version: ${{ env.DEFAULT_PYTHON }}
52-
cache: "poetry"
53-
- name: πŸ— Install workflow dependencies
55+
- name: πŸ“¦ Cache uv
56+
uses: actions/cache@v5
57+
with:
58+
path: |
59+
~/.cache/uv
60+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
61+
restore-keys: |
62+
${{ runner.os }}-uv-
63+
- name: πŸ— Install uv
5464
run: |
55-
poetry config virtualenvs.create true
56-
poetry config virtualenvs.in-project true
65+
curl -LsSf https://astral.sh/uv/install.sh | sh
66+
echo "$HOME/.local/bin" >> $GITHUB_PATH
5767
- name: πŸ— Install Python dependencies
58-
run: poetry install --no-interaction
68+
run: uv sync --all-groups
5969
- name: πŸš€ Run ruff linter
60-
run: poetry run ruff check --output-format=github .
70+
run: uv run ruff check --output-format=github .
6171
- name: πŸš€ Run ruff formatter
62-
run: poetry run ruff format --check .
72+
run: uv run ruff format --check .
6373

6474
prek-builtin-hooks:
6575
name: prek-builtin-hooks
@@ -98,91 +108,111 @@ jobs:
98108
steps:
99109
- name: ‡️ Check out code from GitHub
100110
uses: actions/checkout@v6.0.2
101-
- name: πŸ— Set up Poetry
102-
run: pipx install poetry
103111
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
104112
id: python
105113
uses: actions/setup-python@v6.2.0
106114
with:
107115
python-version: ${{ env.DEFAULT_PYTHON }}
108-
cache: "poetry"
109-
- name: πŸ— Install workflow dependencies
116+
- name: πŸ“¦ Cache uv
117+
uses: actions/cache@v5
118+
with:
119+
path: |
120+
~/.cache/uv
121+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
122+
restore-keys: |
123+
${{ runner.os }}-uv-
124+
- name: πŸ— Install uv
110125
run: |
111-
poetry config virtualenvs.create true
112-
poetry config virtualenvs.in-project true
126+
curl -LsSf https://astral.sh/uv/install.sh | sh
127+
echo "$HOME/.local/bin" >> $GITHUB_PATH
113128
- name: πŸ— Install Python dependencies
114-
run: poetry install --no-interaction
129+
run: uv sync --all-groups
115130
- name: πŸš€ Check Python AST
116-
run: poetry run prek run check-ast --all-files
131+
run: uv run prek run check-ast --all-files
117132
- name: πŸš€ Check docstring is first
118-
run: poetry run prek run check-docstring-first --all-files
133+
run: uv run prek run check-docstring-first --all-files
119134

120135
pylint:
121136
name: pylint
122137
runs-on: ubuntu-latest
123138
steps:
124139
- name: ‡️ Check out code from GitHub
125140
uses: actions/checkout@v6.0.2
126-
- name: πŸ— Set up Poetry
127-
run: pipx install poetry
128141
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
129142
id: python
130143
uses: actions/setup-python@v6.2.0
131144
with:
132145
python-version: ${{ env.DEFAULT_PYTHON }}
133-
cache: "poetry"
134-
- name: πŸ— Install workflow dependencies
146+
- name: πŸ“¦ Cache uv
147+
uses: actions/cache@v5
148+
with:
149+
path: |
150+
~/.cache/uv
151+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
152+
restore-keys: |
153+
${{ runner.os }}-uv-
154+
- name: πŸ— Install uv
135155
run: |
136-
poetry config virtualenvs.create true
137-
poetry config virtualenvs.in-project true
156+
curl -LsSf https://astral.sh/uv/install.sh | sh
157+
echo "$HOME/.local/bin" >> $GITHUB_PATH
138158
- name: πŸ— Install Python dependencies
139-
run: poetry install --no-interaction
159+
run: uv sync --all-groups
140160
- name: πŸš€ Run pylint
141-
run: poetry run prek run pylint --all-files
161+
run: uv run prek run pylint --all-files
142162

143163
yamllint:
144164
name: yamllint
145165
runs-on: ubuntu-latest
146166
steps:
147167
- name: ‡️ Check out code from GitHub
148168
uses: actions/checkout@v6.0.2
149-
- name: πŸ— Set up Poetry
150-
run: pipx install poetry
151169
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
152170
id: python
153171
uses: actions/setup-python@v6.2.0
154172
with:
155173
python-version: ${{ env.DEFAULT_PYTHON }}
156-
cache: "poetry"
157-
- name: πŸ— Install workflow dependencies
174+
- name: πŸ“¦ Cache uv
175+
uses: actions/cache@v5
176+
with:
177+
path: |
178+
~/.cache/uv
179+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
180+
restore-keys: |
181+
${{ runner.os }}-uv-
182+
- name: πŸ— Install uv
158183
run: |
159-
poetry config virtualenvs.create true
160-
poetry config virtualenvs.in-project true
184+
curl -LsSf https://astral.sh/uv/install.sh | sh
185+
echo "$HOME/.local/bin" >> $GITHUB_PATH
161186
- name: πŸ— Install Python dependencies
162-
run: poetry install --no-interaction
187+
run: uv sync --all-groups
163188
- name: πŸš€ Run yamllint
164-
run: poetry run yamllint .
189+
run: uv run yamllint .
165190

166191
prettier:
167192
name: Prettier
168193
runs-on: ubuntu-latest
169194
steps:
170195
- name: ‡️ Check out code from GitHub
171196
uses: actions/checkout@v6.0.2
172-
- name: πŸ— Set up Poetry
173-
run: pipx install poetry
174197
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
175198
id: python
176199
uses: actions/setup-python@v6.2.0
177200
with:
178201
python-version: ${{ env.DEFAULT_PYTHON }}
179-
cache: "poetry"
180-
- name: πŸ— Install workflow dependencies
202+
- name: πŸ“¦ Cache uv
203+
uses: actions/cache@v5
204+
with:
205+
path: |
206+
~/.cache/uv
207+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
208+
restore-keys: |
209+
${{ runner.os }}-uv-
210+
- name: πŸ— Install uv
181211
run: |
182-
poetry config virtualenvs.create true
183-
poetry config virtualenvs.in-project true
212+
curl -LsSf https://astral.sh/uv/install.sh | sh
213+
echo "$HOME/.local/bin" >> $GITHUB_PATH
184214
- name: πŸ— Install Python dependencies
185-
run: poetry install --no-interaction
215+
run: uv sync --all-groups
186216
- name: πŸ— Set up Node.js
187217
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
188218
with:
@@ -191,4 +221,4 @@ jobs:
191221
- name: πŸ— Install NPM dependencies
192222
run: npm install
193223
- name: πŸš€ Run prettier
194-
run: poetry run prek run prettier --all-files
224+
run: uv run prek run prettier --all-files

β€Ž.github/workflows/release.yamlβ€Ž

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,38 @@ jobs:
1414
release:
1515
name: Releasing to PyPi
1616
runs-on: ubuntu-latest
17+
environment: release
18+
permissions:
19+
id-token: write
1720
steps:
1821
- name: ‡️ Check out code from GitHub
1922
uses: actions/checkout@v6.0.2
20-
- name: πŸ— Set up Poetry
21-
run: pipx install poetry
2223
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
2324
id: python
2425
uses: actions/setup-python@v6.2.0
2526
with:
2627
python-version: ${{ env.DEFAULT_PYTHON }}
27-
cache: "poetry"
28-
- name: πŸ— Install workflow dependencies
28+
- name: πŸ“¦ Cache uv
29+
uses: actions/cache@v5
30+
with:
31+
path: |
32+
~/.cache/uv
33+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-uv-
36+
- name: πŸ— Install uv
2937
run: |
30-
poetry config virtualenvs.create true
31-
poetry config virtualenvs.in-project true
38+
curl -LsSf https://astral.sh/uv/install.sh | sh
39+
echo "$HOME/.local/bin" >> $GITHUB_PATH
3240
- name: πŸ— Install dependencies
33-
run: poetry install --no-interaction
41+
run: uv sync --all-groups
3442
- name: πŸ— Set package version
3543
run: |
3644
version="${{ github.event.release.tag_name }}"
3745
version="${version,,}"
3846
version="${version#v}"
39-
poetry version --no-interaction "${version}"
47+
uv version "${version}"
4048
- name: πŸ— Build package
41-
run: poetry build --no-interaction
42-
- name: πŸš€ Publish to PyPi
43-
env:
44-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
45-
run: |
46-
poetry config pypi-token.pypi "${PYPI_TOKEN}"
47-
poetry publish --no-interaction
49+
run: uv build
50+
- name: πŸš€ Publish package to PyPi
51+
uses: pypa/gh-action-pypi-publish@v1.13.0

β€Ž.github/workflows/tests.yamlβ€Ž

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,27 @@ jobs:
2222
steps:
2323
- name: ‡️ Check out code from GitHub
2424
uses: actions/checkout@v6.0.2
25-
- name: πŸ— Set up Poetry
26-
run: pipx install poetry
2725
- name: πŸ— Set up Python ${{ matrix.python }}
2826
id: python
2927
uses: actions/setup-python@v6.2.0
3028
with:
3129
python-version: ${{ matrix.python }}
32-
cache: "poetry"
33-
- name: πŸ— Install workflow dependencies
30+
- name: πŸ“¦ Cache uv
31+
uses: actions/cache@v5
32+
with:
33+
path: |
34+
~/.cache/uv
35+
key: ${{ runner.os }}-uv-${{ matrix.python }}-${{ hashFiles('uv.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-uv-${{ matrix.python }}-
38+
- name: πŸ— Install uv
3439
run: |
35-
poetry config virtualenvs.create true
36-
poetry config virtualenvs.in-project true
40+
curl -LsSf https://astral.sh/uv/install.sh | sh
41+
echo "$HOME/.local/bin" >> $GITHUB_PATH
3742
- name: πŸ— Install dependencies
38-
run: poetry install --no-interaction
43+
run: uv sync --all-groups
3944
- name: πŸš€ Run pytest
40-
run: poetry run pytest --cov src tests
45+
run: uv run pytest --cov src tests
4146
- name: ⬆️ Upload coverage artifact
4247
uses: actions/upload-artifact@v7.0.1
4348
with:
@@ -55,24 +60,29 @@ jobs:
5560
fetch-depth: 0
5661
- name: ⬇️ Download coverage data
5762
uses: actions/download-artifact@v8.0.1
58-
- name: πŸ— Set up Poetry
59-
run: pipx install poetry
6063
- name: πŸ— Set up Python ${{ env.DEFAULT_PYTHON }}
6164
id: python
6265
uses: actions/setup-python@v6.2.0
6366
with:
6467
python-version: ${{ env.DEFAULT_PYTHON }}
65-
cache: "poetry"
66-
- name: πŸ— Install workflow dependencies
68+
- name: πŸ“¦ Cache uv
69+
uses: actions/cache@v5
70+
with:
71+
path: |
72+
~/.cache/uv
73+
key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
74+
restore-keys: |
75+
${{ runner.os }}-uv-
76+
- name: πŸ— Install uv
6777
run: |
68-
poetry config virtualenvs.create true
69-
poetry config virtualenvs.in-project true
78+
curl -LsSf https://astral.sh/uv/install.sh | sh
79+
echo "$HOME/.local/bin" >> $GITHUB_PATH
7080
- name: πŸ— Install dependencies
71-
run: poetry install --no-interaction
81+
run: uv sync --all-groups
7282
- name: πŸš€ Process coverage results
7383
run: |
74-
poetry run coverage combine coverage*/.coverage*
75-
poetry run coverage xml -i
84+
uv run coverage combine coverage*/.coverage*
85+
uv run coverage xml -i
7686
- name: πŸš€ Upload coverage report
7787
uses: codecov/codecov-action@v6.0.1
7888
with:

0 commit comments

Comments
Β (0)