Skip to content

Commit 8c47628

Browse files
authored
Migrate from Poetry to UV and bring project up to speed with 2026 standards (#461)
1 parent 1cbde70 commit 8c47628

20 files changed

Lines changed: 1467 additions & 2121 deletions

.devcontainer/devcontainer.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,31 @@
77
// Features to add to the dev container. More info: https://containers.dev/features.
88
"features": {
99
"ghcr.io/devcontainers/features/github-cli:1": {},
10-
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
10+
"ghcr.io/va-h/devcontainers-features/uv:1": {}
1111
},
1212
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1313
// "forwardPorts": [],
1414
// Use 'postCreateCommand' to run commands after the container is created.
15-
"postCreateCommand": "poetry config virtualenvs.in-project true && poetry install --with dev --no-interaction && . .venv/bin/activate && pre-commit install && pre-commit install-hooks",
15+
"postCreateCommand": "uv sync --all-groups && uv run prek install -f",
1616
// Configure tool-specific properties.
1717
"customizations": {
1818
"vscode": {
1919
"extensions": [
2020
"ms-python.python",
21-
"yzhang.markdown-all-in-one"
21+
"yzhang.markdown-all-in-one",
22+
"charliermarsh.ruff"
2223
],
23-
"settings": {
24-
"python.defaultInterpreterPath": "./.venv/bin/python"
24+
"python.testing.pytestArgs": [
25+
"tests"
26+
],
27+
"python.testing.unittestEnabled": false,
28+
"python.testing.pytestEnabled": true,
29+
"[python]": {
30+
"editor.formatOnSave": true,
31+
"editor.defaultFormatter": "charliermarsh.ruff",
32+
"editor.codeActionsOnSave": {
33+
"source.organizeImports.ruff": "explicit"
34+
}
2535
}
2636
}
2737
}

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: uv
44
directory: "/"
55
schedule:
6-
interval: "daily"
6+
interval: "weekly"
77
time: "08:00"
88
open-pull-requests-limit: 10
99

1010
- package-ecosystem: github-actions
1111
directory: "/"
1212
schedule:
13-
interval: "daily"
13+
interval: "weekly"
1414
time: "08:00"
1515
open-pull-requests-limit: 10

.github/workflows/main.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.9", "3.10", "3.11", "3.12"]
18+
python-version: ["3.11", "3.12", "3.13", "3.14"]
1919

2020
steps:
2121
- uses: actions/checkout@v6
@@ -25,30 +25,32 @@ jobs:
2525
with:
2626
python-version: "${{ matrix.python-version }}"
2727

28-
- name: Set up Poetry
29-
uses: Gr1N/setup-poetry@v9
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v7
30+
with:
31+
enable-cache: true
3032

3133
- name: Cache venv
3234
uses: actions/cache@v5
3335
with:
3436
path: .venv
35-
key: venv-${{ hashFiles('**/poetry.lock') }}
37+
key: venv-${{ hashFiles('**/uv.lock') }}
3638

37-
- name: Cache pre-commit
39+
- name: Cache prek
3840
uses: actions/cache@v5
3941
with:
40-
path: ~/.cache/pre-commit/
41-
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} # yamllint disable-line
42+
path: ~/.cache/prek/
43+
key: ${{ runner.os }}-prek-${{ hashFiles('**/uv.lock') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} # yamllint disable-line
4244

4345
- name: Install dependencies
44-
run: poetry install
46+
run: uv sync --all-groups
4547

4648
- name: Register problems matchers
4749
run: |
48-
echo "::add-matcher::.github/workflows/matchers/pylint.json"
49-
echo "::add-matcher::.github/workflows/matchers/flake8.json"
5050
echo "::add-matcher::.github/workflows/matchers/mypy.json"
5151
echo "::add-matcher::.github/workflows/matchers/python.json"
5252
53-
- name: Apply all pre-commit
54-
run: poetry run pre-commit run -a
53+
- name: Run prek (pre-commit checks)
54+
env:
55+
SKIP: ${{ github.ref == 'refs/heads/main' && 'no-commit-to-branch' || '' }}
56+
run: uv run prek run --show-diff-on-failure --color=always --all-files

.github/workflows/matchers/flake8.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/matchers/pylint.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/pr-labeler.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name: PR Labeler
2+
permissions:
3+
contents: read
4+
pull-requests: write
25
on:
36
pull_request:
47
types: [opened]

.github/workflows/publish-pypi-test.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/release-drafter.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ on:
88
jobs:
99
update_release_draft:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: read
1114
steps:
1215
- name: Update release draft
13-
uses: release-drafter/release-drafter@v6
16+
uses: release-drafter/release-drafter@v7
1417
env:
1518
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# This workflow will upload a Python Package using
2-
# Poetry when a release is published
1+
# This workflow will upload the package to PyPi when a release is published
32

43
name: Publish Python Package (PyPi)
54

@@ -13,32 +12,48 @@ jobs:
1312
environment: release
1413

1514
permissions:
16-
# IMPORTANT: this permission is mandatory for trusted publishing
15+
# IMPORTANT: this permission is mandatory for trusted publishing via PyPi
1716
id-token: write
17+
contents: write
1818

1919
steps:
2020
- uses: actions/checkout@v6
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
24+
2125
- name: Set up Python
2226
uses: actions/setup-python@v6
2327
with:
24-
python-version: '3.x'
25-
- name: Set up Poetry
26-
uses: Gr1N/setup-poetry@v9
27-
- name: Bump Poetry version
28+
python-version: "3.x"
29+
30+
- name: Retrieve version from tag name
31+
id: retrieve-version
2832
run: |
29-
tag=${{ github.event.release.tag_name }}
30-
version_number=${tag#?}
31-
poetry version $version_number
32-
- name: Commit changes
33-
uses: EndBug/add-and-commit@v4
34-
with:
35-
message: "Bump version to ${{ github.event.release.tag_name }}"
36-
add: "pyproject.toml"
37-
ref: "main"
38-
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
- name: Build package distribution
33+
tag="${{ github.event.release.tag_name }}"
34+
version_number="${tag#?}"
35+
echo "version: $version_number"
36+
echo "version=$version_number" >> "$GITHUB_OUTPUT"
37+
38+
- name: Bump project version in pyproject.toml and commit changes to current branch and tag
39+
run: |
40+
VERSION=${{ steps.retrieve-version.outputs.version }}
41+
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION
42+
43+
git config --local user.email "action@github.com"
44+
git config --local user.name "GitHub Action"
45+
46+
git add pyproject.toml
47+
git commit -m "Bump package version to ${{ steps.retrieve-version.outputs.version }}."
48+
49+
git tag -f -a ${{ github.event.release.tag_name }} -m "Release ${{ steps.retrieve-version.outputs.version }}."
50+
git push origin HEAD:main
51+
git push origin -f ${{ github.event.release.tag_name }}
52+
53+
- name: Build package
54+
run: |
55+
uv build
56+
57+
- name: Publish package to PyPI
4158
run: |
42-
poetry build
43-
- name: Publish package distributions to PyPI
44-
uses: pypa/gh-action-pypi-publish@release/v1
59+
uv publish

.pre-commit-config.yaml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
13
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
# Ruff version.
6+
rev: v0.14.10
7+
hooks:
8+
# Run the linter.
9+
- id: ruff-check
10+
args: [ --fix ]
11+
# Run the formatter.
12+
- id: ruff-format
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v6.0.0
415
hooks:
5-
- id: check-json
16+
- id: trailing-whitespace
17+
- id: end-of-file-fixer
18+
- id: check-json
619
exclude: .devcontainer
7-
- id: check-yaml
8-
- id: trailing-whitespace
9-
- id: end-of-file-fixer
10-
- repo: local
20+
- id: check-yaml
21+
- id: check-added-large-files
22+
- id: no-commit-to-branch
23+
stages: [pre-commit]
24+
args: [--branch, main]
25+
- repo: https://github.com/rhysd/actionlint
26+
rev: v1.7.7
27+
hooks:
28+
- id: actionlint
29+
- repo: local
1130
hooks:
12-
- id: black
13-
name: black
14-
entry: black
15-
language: system
16-
types: [ python ]
17-
- id: flake8
18-
name: flake8
19-
entry: flake8
20-
language: system
21-
types: [ python ]
22-
- id: isort
23-
name: isort
24-
entry: isort
25-
language: system
26-
types: [ python ]
27-
- id: pyupgrade
28-
name: pyupgrade
29-
entry: pyupgrade
30-
args: ["--py37-plus"]
31-
language: system
32-
types: [ python ]
3331
- id: mypy
3432
name: mypy
3533
entry: mypy
3634
language: system
3735
types: [ python ]
38-
- id: pylint
39-
name: pylint
40-
entry: pylint
36+
exclude: tests
37+
- id: ty
38+
name: ty check
39+
entry: uv run ty check .
4140
language: system
4241
types: [ python ]
42+
exclude: tests

0 commit comments

Comments
 (0)