Skip to content

Commit d27d747

Browse files
authored
Merge pull request #114 from malmeloo/migrate-uv
chore: Migrate from poetry to uv
2 parents 515c3df + 0d58aba commit d27d747

File tree

19 files changed

+1840
-2175
lines changed

19 files changed

+1840
-2175
lines changed
Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,25 @@
1-
name: Common Python + Poetry Setup
1+
name: Common Python + UV Setup
22

33
inputs:
4-
dependency-groups:
5-
description: 'A comma-separated list of dependency groups to install'
6-
default: 'main'
74
python-version:
8-
description: 'The Python version to use'
9-
default: '3.10'
5+
description: 'The Python version to install'
6+
required: false
107

118
runs:
129
using: 'composite'
1310

1411
steps:
15-
- name: Set up Python
16-
uses: actions/setup-python@v5
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v5
1714
with:
18-
python-version: ${{ inputs.python-version }}
19-
20-
- name: Install poetry
21-
shell: bash
22-
run: |
23-
python -m pip install poetry
24-
poetry config virtualenvs.in-project true
25-
26-
- name: Get cache key
27-
id: cache-key
28-
shell: bash
29-
run: |
30-
key=$(echo "${{ inputs.dependency-groups }}" | sed 's/,/+/')
31-
echo "key=$key" >> "$GITHUB_OUTPUT"
15+
enable-cache: true
16+
python-version: ${{ matrix.python-version }}
3217

33-
- name: Get full Python version
34-
id: full-python-version
18+
- name: Set up Python
19+
if: ${{ inputs.python-version != '' }}
3520
shell: bash
36-
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
37-
38-
- name: Load cached venv
39-
id: cache-dependencies
40-
uses: actions/cache@v4
41-
with:
42-
path: .venv
43-
key: venv-${{ runner.os }}-py${{ steps.full-python-version.outputs.version }}-grp${{ steps.cache-key.outputs.key }}-${{ hashFiles('**/poetry.lock') }}
21+
run: uv python install
4422

4523
- name: Install dependencies
46-
if: steps.cache-dependencies.outputs.cache-hit != 'true'
4724
shell: bash
48-
run: poetry install --with ${{ inputs.dependency-groups }}
25+
run: uv sync --all-extras --all-groups

.github/workflows/docs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20-
- uses: './.github/actions/setup-project'
20+
- name: Install uv and set the python version
21+
uses: astral-sh/setup-uv@v5
2122
with:
22-
dependency-groups: 'docs'
23+
python-version: ${{ matrix.python-version }}
2324

2425
- name: Build documentation
2526
run: |
2627
cd docs
27-
poetry run make html
28+
uv run make html
2829
2930
- name: Setup Pages
3031
uses: actions/configure-pages@v5

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ jobs:
1414
- uses: actions/checkout@v4
1515

1616
- uses: './.github/actions/setup-project'
17-
with:
18-
dependency-groups: 'dev,test'
1917

2018
- uses: pre-commit/action@v3.0.1
2119

.github/workflows/publish.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ jobs:
1717
- uses: actions/checkout@v4
1818

1919
- uses: './.github/actions/setup-project'
20-
with:
21-
dependency-groups: 'dev'
2220

2321
- name: Prepare README
2422
run: ./scripts/refactor_readme.py README.md
2523

2624
- name: Build package
27-
run: poetry build
25+
run: uv build
2826

2927
- name: Publish package
3028
run: |
31-
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
32-
poetry publish
29+
uv publish --token ${{ secrets.PYPI_API_TOKEN }}
3330
3431
- name: Create release
3532
uses: softprops/action-gh-release@v2

.github/workflows/test.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ jobs:
1717
- uses: actions/checkout@v4
1818

1919
- uses: './.github/actions/setup-project'
20-
with:
21-
dependency-groups: 'dev'
2220

2321
- id: supported-versions
2422
name: Get supported versions
2523
run: |
2624
set -e
27-
echo "py-versions=$(poetry run ./scripts/supported_py_versions.py)" >> "$GITHUB_OUTPUT"
25+
echo "py-versions=$(uv run ./scripts/supported_py_versions.py)" >> "$GITHUB_OUTPUT"
2826
2927
test:
3028
runs-on: ubuntu-latest
@@ -40,10 +38,9 @@ jobs:
4038
- uses: './.github/actions/setup-project'
4139
with:
4240
python-version: ${{ matrix.py-version }}
43-
dependency-groups: 'test'
4441

4542
- name: Run unit tests
46-
run: poetry run pytest
43+
run: uv run pytest
4744

4845
results:
4946
runs-on: ubuntu-latest

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ Before opening a pull request, please ensure that your code adheres to these rul
6666
There are pre-commit hooks included to help you with this, which you can set up as follows:
6767

6868
```shell
69-
pip install poetry
70-
poetry install --with dev # this installs pre-commit into your environment
69+
pip install uv
70+
uv sync # this installs ruff & pre-commit into your environment
7171
pre-commit install
7272
```
7373

findmy/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from .keys import KeyPair
66

77
__all__ = (
8+
"FindMyAccessory",
9+
"KeyPair",
10+
"errors",
811
"keys",
912
"reports",
1013
"scanner",
11-
"errors",
12-
"FindMyAccessory",
13-
"KeyPair",
1414
)

findmy/accessory.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
import plistlib
1111
from abc import ABC, abstractmethod
1212
from datetime import datetime, timedelta, timezone
13-
from typing import IO, Generator, overload
13+
from typing import IO, TYPE_CHECKING, overload
1414

1515
from typing_extensions import override
1616

1717
from .keys import KeyGenerator, KeyPair, KeyType
1818
from .util import crypto
1919

20+
if TYPE_CHECKING:
21+
from collections.abc import Generator
22+
2023
logging.getLogger(__name__)
2124

2225

findmy/keys.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
import secrets
88
from abc import ABC, abstractmethod
99
from enum import Enum
10-
from typing import Generator, Generic, TypeVar, overload
10+
from typing import TYPE_CHECKING, Generic, TypeVar, overload
1111

1212
from cryptography.hazmat.primitives.asymmetric import ec
1313
from typing_extensions import override
1414

1515
from .util import crypto, parsers
1616

17+
if TYPE_CHECKING:
18+
from collections.abc import Generator
19+
1720

1821
class KeyType(Enum):
1922
"""Enum of possible key types."""

findmy/reports/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
__all__ = (
99
"AppleAccount",
1010
"AsyncAppleAccount",
11-
"LoginState",
1211
"BaseAnisetteProvider",
12+
"LoginState",
1313
"RemoteAnisetteProvider",
1414
"SmsSecondFactorMethod",
1515
"TrustedDeviceSecondFactorMethod",

0 commit comments

Comments
 (0)