Skip to content

Commit 37f86f6

Browse files
authored
Migrate from poetry to uv (#926)
1 parent 8852430 commit 37f86f6

File tree

10 files changed

+2277
-4077
lines changed

10 files changed

+2277
-4077
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "Common steps to install and cache dependencies"
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Install uv
7+
uses: astral-sh/setup-uv@v3
8+
with:
9+
enable-cache: true
10+
11+
- name: Set up Python
12+
shell: bash
13+
run: |
14+
uv python install
15+
echo "PYTHON_VERSION=$(uv run python -c 'import platform; print(platform.python_version())')" >> "$GITHUB_ENV"
16+
17+
- name: Install dependencies with uv
18+
shell: bash
19+
run: uv sync

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dependencies:
2-
- any: ["poetry.lock"]
2+
- any: ["uv.lock"]
33
all: ["!**/*.py"]
44

55
documentation:

.github/workflows/home-assistant.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
- master
77
pull_request:
88

9-
env:
10-
DEFAULT_PYTHON: "3.12"
11-
129
jobs:
1310
hacs:
1411
runs-on: ubuntu-latest

.github/workflows/linting.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
- master
77
pull_request:
88

9-
env:
10-
PYTHON_VERSION: "3.12"
11-
129
jobs:
1310
pre-commit:
1411
name: Pre-commit
@@ -17,23 +14,27 @@ jobs:
1714
- name: Check out the repository
1815
uses: actions/checkout@v4
1916

20-
- name: Set up Python ${{ env.PYTHON_VERSION }}
21-
uses: actions/setup-python@v5
22-
with:
23-
python-version: ${{ env.PYTHON_VERSION }}
17+
- name: Prepare and install deps
18+
uses: ./.github/actions/install-deps
2419

25-
- name: Install Poetry
26-
uses: abatilo/[email protected]
20+
- uses: actions/cache@v4
21+
name: Cache pre-commit hooks
2722
with:
28-
poetry-version: 1.3.2
29-
30-
- name: Install dependencies
31-
run: poetry install
23+
path: ~/.cache/pre-commit/
24+
key: >
25+
${{ format('pre-commit-{0}-{1}-{2}',
26+
runner.os,
27+
matrix.python-version,
28+
hashFiles('.pre-commit-config.yaml')
29+
) }}
30+
restore-keys: |
31+
pre-commit-${{ runner.os }}-${{ matrix.python-version }}-
32+
pre-commit-${{ runner.os }}-
3233
3334
- name: Run pre-commit on all files
3435
run: |
35-
poetry run pre-commit run --all-files --show-diff-on-failure --color=always
36+
uvx pre-commit run --all-files --show-diff-on-failure --color=always
3637
3738
- name: Run python-typing-update
3839
run: |
39-
poetry run pre-commit run --hook-stage manual python-typing-update --all-files --show-diff-on-failure --color=always
40+
uvx pre-commit run --hook-stage manual python-typing-update --all-files --show-diff-on-failure --color=always

.github/workflows/publish-release.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name: Publish new release
33
on:
44
workflow_dispatch:
55

6-
env:
7-
PYTHON_VERSION: "3.12"
8-
96
jobs:
107
publish:
118
name: Update manifest and publish
@@ -14,21 +11,11 @@ jobs:
1411
- name: Check out the repository
1512
uses: actions/checkout@v4
1613

17-
- name: Set up Python ${{ env.PYTHON_VERSION }}
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: ${{ env.PYTHON_VERSION }}
21-
22-
- name: Install Poetry
23-
uses: abatilo/[email protected]
24-
with:
25-
poetry-version: 1.3.2
26-
27-
- name: Install dependencies
28-
run: poetry install
14+
- name: Prepare and install deps
15+
uses: ./.github/actions/install-deps
2916

3017
- name: Run script
3118
run: |
32-
poetry run python script/publish_release.py
19+
uv run python script/publish_release.py
3320
env:
3421
GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }}

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ repos:
1111
hooks:
1212
- id: ruff-format
1313
name: ruff format
14-
entry: poetry run ruff format
14+
entry: uv run ruff format
1515
language: system
1616
types: [python]
1717
require_serial: true
1818
- id: ruff-check
1919
name: ruff check
20-
entry: poetry run ruff check --fix
20+
entry: uv run ruff check --fix
2121
language: system
2222
types: [python]
2323
require_serial: true
2424
- id: mypy
2525
name: mypy
26-
entry: poetry run mypy
26+
entry: uv run mypy
2727
language: system
2828
types: [python]
2929
require_serial: true
3030
- id: pylint
3131
name: pylint
32-
entry: poetry run pylint
32+
entry: uv run pylint
3333
language: system
3434
types: [python]
3535
require_serial: true
3636
- id: codespell
3737
name: codespell
38-
entry: poetry run codespell --write-changes
38+
entry: uv run codespell --write-changes
3939
language: system
4040
pass_filenames: false
4141
always_run: true

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ People _love_ thorough bug reports. I'm not even kidding.
4848

4949
## Use a Consistent Coding Style
5050

51-
Install [Poetry](https://python-poetry.org/docs/#installation) to setup the developer environment.
52-
It uses [black](https://github.com/ambv/black) and [prettier](https://prettier.io/)
51+
Install [uv](https://docs.astral.sh/uv/getting-started/installation/) to setup the developer environment.
52+
It uses [ruff](https://docs.astral.sh/ruff/) and [prettier](https://prettier.io/)
5353
to make sure the code follows the style.
5454

5555
`pre-commit` can be used to run all checks with one command (see dedicated section below).
@@ -74,7 +74,7 @@ When writing unittests please follow the good practises like:
7474

7575
## Pre-commit
7676

77-
With Poetry installed, run `poetry install` in the repo root.
77+
With uv installed, run `uv sync` in the repo root.
7878
It will create a virtualenv with all required packages.
7979

8080
After that you can run [pre-commit](https://pre-commit.com/) with settings included in the
@@ -83,13 +83,13 @@ repository to have code style and linting checks.
8383
Activate `pre-commit` git hook:
8484

8585
```console
86-
$ poetry run pre-commit install
86+
$ uvx pre-commit install
8787
```
8888

8989
Now the pre-commit tests will be done every time you commit.
9090

9191
You can also run the tests on all repository files manually with this command:
9292

9393
```console
94-
$ poetry run pre-commit run --all-files
94+
$ uvx pre-commit run --all-files
9595
```

0 commit comments

Comments
 (0)