Skip to content

Commit 6474b86

Browse files
committed
refactor: update python version, move to uv
1 parent c584570 commit 6474b86

File tree

10 files changed

+1769
-1316
lines changed

10 files changed

+1769
-1316
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ name: Release python package
33
on:
44
push:
55
tags:
6-
- "*"
6+
- released
77

88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
1113
steps:
12-
- uses: actions/checkout@v2
13-
- name: Set up Python
14-
uses: actions/setup-python@v2
14+
- uses: actions/checkout@v5
1515
with:
16-
python-version: "3.11"
17-
- name: Install deps
18-
uses: knowsuchagency/poetry-install@v1
19-
env:
20-
POETRY_VIRTUALENVS_CREATE: false
21-
- name: Set version
22-
run: poetry version "${{ github.ref_name }}"
16+
persist-credentials: false
17+
- uses: astral-sh/setup-uv@v7
18+
with:
19+
enable-cache: false
20+
python-version: "3.12"
21+
version: "latest"
22+
- run: uv version "${GITHUB_REF_NAME}"
23+
- run: uv build
2324
- name: Release package
2425
env:
25-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
26-
run: poetry publish --build
26+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
27+
run: uv publish

.github/workflows/test.yml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,53 @@ jobs:
1111
lint:
1212
strategy:
1313
matrix:
14-
cmd:
15-
- black
16-
- ruff
17-
- mypy
14+
cmd: [ "black", "ruff", "mypy" ]
1815
runs-on: ubuntu-latest
1916
steps:
20-
- uses: actions/checkout@v4
21-
- name: Install poetry
22-
run: pipx install poetry
23-
- name: Set up Python
24-
uses: actions/setup-python@v4
17+
- uses: actions/checkout@v5
18+
with:
19+
persist-credentials: false
20+
- id: setup-uv
21+
uses: astral-sh/setup-uv@v7
2522
with:
26-
python-version: "3.11"
27-
cache: "poetry"
23+
enable-cache: true
24+
cache-suffix: "3.12"
25+
version: "latest"
26+
python-version: "3.12"
2827
- name: Install deps
29-
run: poetry install
28+
run: uv sync --all-extras
3029
- name: Run lint check
31-
run: poetry run pre-commit run -a ${{ matrix.cmd }}
30+
run: uv run pre-commit run -a ${{ matrix.cmd }}
3231
pytest:
3332
strategy:
3433
matrix:
35-
py_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
34+
py_version: [ "3.10", "3.11", "3.12", "3.13" ]
3635
runs-on: "ubuntu-latest"
3736
steps:
38-
- uses: actions/checkout@v4
37+
- uses: actions/checkout@v5
3938
- name: Set up Redis instance and Redis cluster
4039
run: docker compose up -d
4140
- name: Set up Python
42-
uses: actions/setup-python@v2
41+
uses: actions/setup-python@v6
42+
with:
43+
python-version: "${{ matrix.py_version }}"
44+
- name: Set up uv and enable cache
45+
id: setup-uv
46+
uses: astral-sh/setup-uv@v7
4347
with:
48+
enable-cache: true
49+
cache-suffix: "${{ matrix.py_version }}"
50+
version: "latest"
4451
python-version: "${{ matrix.py_version }}"
45-
- name: Update pip
46-
run: python -m pip install -U pip
47-
- name: Install poetry
48-
run: python -m pip install poetry
4952
- name: Install deps
50-
run: poetry install
51-
env:
52-
POETRY_VIRTUALENVS_CREATE: false
53-
- name: Run pytest check
54-
run: poetry run pytest -vv -n auto --cov="taskiq_redis" .
55-
- name: Generate report
56-
run: poetry run coverage xml
53+
run: uv sync --all-extras
54+
- name: Run pytest
55+
run: uv run pytest -vv -n auto --cov="taskiq_redis" .
56+
- name: Generate coverage report
57+
run: uv run coverage xml
5758
- name: Upload coverage reports to Codecov with GitHub Action
58-
uses: codecov/codecov-action@v3
59-
if: matrix.py_version == '3.9'
59+
uses: codecov/codecov-action@v4
60+
if: matrix.py_version == '3.10'
6061
with:
6162
token: ${{ secrets.CODECOV_TOKEN }}
6263
fail_ci_if_error: false

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ repos:
1818
hooks:
1919
- id: black
2020
name: Format with Black
21-
entry: poetry run black
21+
entry: uv run black
2222
language: system
2323
types: [python]
2424

2525
- id: ruff
2626
name: Run ruff lints
27-
entry: poetry run ruff
27+
entry: uv run ruff
2828
language: system
2929
pass_filenames: false
3030
types: [python]
@@ -36,6 +36,6 @@ repos:
3636

3737
- id: mypy
3838
name: Validate types with MyPy
39-
entry: poetry run mypy
39+
entry: uv run mypy
4040
language: system
4141
types: [ python ]

poetry.lock

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

pyproject.toml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ authors = [
88
maintainers = [
99
{ name = "Taskiq team", email = "[email protected]" }
1010
]
11-
license = { file = "LICENSE" }
11+
license = "MIT"
12+
license-files = ["LICENSE"]
1213
readme = "README.md"
1314
requires-python = ">=3.10"
1415
classifiers = [
@@ -28,25 +29,24 @@ keywords = [
2829
"redis",
2930
"result_backend",
3031
]
31-
3232
dependencies = [
33-
"taskiq>=0.11.12,<1",
34-
"redis>=6",
33+
"redis>=7.1.0",
34+
"taskiq>=0.12.0",
3535
]
3636

3737
[project.optional-dependencies]
3838
dev = [
39-
"pytest>=8",
40-
"mypy>=1",
41-
"black>=25",
42-
"pytest-cov>=6",
43-
"anyio>=4",
44-
"pytest-env>=1",
45-
"fakeredis>=2",
46-
"pre-commit>=4",
47-
"pytest-xdist>=3; extra == 'psutil'",
48-
"ruff>=0",
49-
"freezegun>=1.5.1",
39+
"anyio>=4.12.0",
40+
"black>=25.11.0",
41+
"fakeredis>=2.32.1",
42+
"freezegun>=1.5.5",
43+
"mypy>=1.19.0",
44+
"pre-commit>=4.5.0",
45+
"pytest>=9.0.1",
46+
"pytest-cov>=7.0.0",
47+
"pytest-env>=1.2.0",
48+
"pytest-xdist>=3.8.0",
49+
"ruff>=0.14.7",
5050
]
5151

5252
[project.urls]
@@ -71,11 +71,12 @@ ignore_errors = true
7171
strict = false
7272

7373
[build-system]
74-
requires = ["hatchling>=1.21"]
75-
build-backend = "hatchling.build"
74+
requires = ["uv_build>=0.9.13,<0.10.0"]
75+
build-backend = "uv_build"
7676

77-
[tool.hatch.build.targets.wheel]
78-
packages = ["taskiq_redis"]
77+
[tool.uv.build-backend]
78+
module-root = ""
79+
module-name = "taskiq_redis"
7980

8081
[tool.ruff]
8182
# List of enabled rulsets.

taskiq_redis/list_schedule_source.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from logging import getLogger
3-
from typing import Any, List, Optional
3+
from typing import Any
44

55
from redis.asyncio import BlockingConnectionPool, Redis
66
from taskiq import ScheduledTask, ScheduleSource
@@ -19,8 +19,8 @@ def __init__(
1919
self,
2020
url: str,
2121
prefix: str = "schedule",
22-
max_connection_pool_size: Optional[int] = None,
23-
serializer: Optional[TaskiqSerializer] = None,
22+
max_connection_pool_size: int | None = None,
23+
serializer: TaskiqSerializer | None = None,
2424
buffer_size: int = 50,
2525
skip_past_schedules: bool = False,
2626
**connection_kwargs: Any,
@@ -48,7 +48,7 @@ def __init__(
4848
serializer = PickleSerializer()
4949
self._serializer = serializer
5050
self._is_first_run = True
51-
self._previous_schedule_source: Optional[ScheduleSource] = None
51+
self._previous_schedule_source: ScheduleSource | None = None
5252
self._delete_schedules_after_migration: bool = True
5353
self._skip_past_schedules = skip_past_schedules
5454

@@ -89,7 +89,7 @@ def _get_data_key(self, schedule_id: str) -> str:
8989
"""Get the key for a schedule data."""
9090
return f"{self._prefix}:data:{schedule_id}"
9191

92-
def _parse_time_key(self, key: str) -> Optional[datetime.datetime]:
92+
def _parse_time_key(self, key: str) -> datetime.datetime | None:
9393
"""Get time value from the timed-key."""
9494
try:
9595
dt_str = key.split(":", 2)[2]
@@ -175,7 +175,7 @@ async def post_send(self, task: ScheduledTask) -> None:
175175
if task.time is not None:
176176
await self.delete_schedule(task.schedule_id)
177177

178-
async def get_schedules(self) -> List["ScheduledTask"]:
178+
async def get_schedules(self) -> list["ScheduledTask"]:
179179
"""
180180
Get all schedules.
181181

0 commit comments

Comments
 (0)