Skip to content

Commit 6454070

Browse files
committed
feat: replace poetry with uv and remove support for python 3.8/3.9
1 parent ff191ca commit 6454070

File tree

13 files changed

+1838
-1384
lines changed

13 files changed

+1838
-1384
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
name: Release python package
22

33
on:
4-
push:
5-
tags:
6-
- "*"
4+
release:
5+
types:
6+
- released
77

88
jobs:
99
deploy:
1010
runs-on: ubuntu-latest
11+
environment:
12+
name: release
13+
permissions:
14+
id-token: write
1115
steps:
12-
- uses: actions/checkout@v2
13-
- name: Install poetry
14-
run: pipx install poetry
15-
- name: Set up Python
16-
uses: actions/setup-python@v4
16+
- uses: actions/checkout@v5
1717
with:
18-
python-version: "3.11"
19-
- name: Install deps
20-
run: poetry install
21-
- name: Set verison
22-
run: poetry version "${{ github.ref_name }}"
23-
- name: Release package
24-
env:
25-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
26-
run: poetry publish --build
18+
persist-credentials: false
19+
- uses: astral-sh/setup-uv@v7
20+
with:
21+
enable-cache: false
22+
python-version: "3.12"
23+
version: "latest"
24+
- run: uv version "${GITHUB_REF_NAME}"
25+
- run: uv build
26+
- run: uv publish --trusted-publishing always

.github/workflows/test.yml

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
name: Testing taskiq-aio-pika
22

3-
on: [push, pull_request]
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '*.md'
7+
push:
8+
paths-ignore:
9+
- '*.md'
10+
11+
permissions:
12+
actions: read
13+
contents: read
14+
pull-requests: read
415

516
jobs:
617
lint:
718
strategy:
819
matrix:
9-
cmd:
10-
- black
11-
- ruff
12-
- mypy
20+
cmd: ["black", "ruff", "mypy"]
1321
runs-on: ubuntu-latest
1422
steps:
15-
- uses: actions/checkout@v2
16-
- name: Install poetry
17-
run: pipx install poetry
18-
- name: Set up Python
19-
uses: actions/setup-python@v4
23+
- uses: actions/checkout@v5
24+
with:
25+
persist-credentials: false
26+
- id: setup-uv
27+
uses: astral-sh/setup-uv@v7
2028
with:
21-
python-version: "3.11"
22-
cache: "poetry"
29+
enable-cache: true
30+
cache-suffix: 3.11
31+
version: "latest"
32+
python-version: 3.11
2333
- name: Install deps
24-
run: poetry install
34+
run: uv sync --all-extras
2535
- name: Run lint check
26-
run: poetry run pre-commit run -a ${{ matrix.cmd }}
36+
run: uv run pre-commit run -a ${{ matrix.cmd }}
2737
pytest:
2838
services:
2939
rabbit:
@@ -41,18 +51,20 @@ jobs:
4151
- 5672:5672
4252
strategy:
4353
matrix:
44-
py_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
54+
py_version: ["3.10", "3.11", "3.12", "3.13"]
4555
runs-on: "ubuntu-latest"
4656
steps:
47-
- uses: actions/checkout@v2
48-
- name: Install poetry
49-
run: pipx install poetry
50-
- name: Set up Python
51-
uses: actions/setup-python@v4
57+
- uses: actions/checkout@v5
58+
with:
59+
persist-credentials: false
60+
- id: setup-uv
61+
uses: astral-sh/setup-uv@v7
5262
with:
53-
python-version: "${{ matrix.py_version }}"
54-
cache: "poetry"
63+
enable-cache: true
64+
cache-suffix: ${{ matrix.py_version }}
65+
version: "latest"
66+
python-version: ${{ matrix.py_version }}
5567
- name: Install deps
56-
run: poetry install
68+
run: uv sync --all-extras
5769
- name: Run pytest check
58-
run: poetry run pytest -vv -n auto --cov="taskiq_aio_pika" .
70+
run: uv run pytest -vv -n auto --cov="taskiq_aio_pika" .

.pre-commit-config.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,42 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v2.4.0
5+
rev: v6.0.0
66
hooks:
77
- id: check-ast
88
- id: trailing-whitespace
99
- id: check-toml
1010
- id: end-of-file-fixer
1111

1212
- repo: https://github.com/asottile/add-trailing-comma
13-
rev: v2.1.0
13+
rev: v4.0.0
1414
hooks:
1515
- id: add-trailing-comma
1616

17+
- repo: https://github.com/crate-ci/typos
18+
rev: v1.38.1
19+
hooks:
20+
- id: typos
21+
22+
- repo: https://github.com/Yelp/detect-secrets
23+
rev: v1.5.0
24+
hooks:
25+
- id: detect-secrets
26+
args: [
27+
'--exclude-lines', 'amqp://guest:guest@localhost:5672',
28+
]
29+
1730
- repo: local
1831
hooks:
1932
- id: black
2033
name: Format with Black
21-
entry: poetry run black
34+
entry: uv run black
2235
language: system
2336
types: [python]
2437

2538
- id: ruff
2639
name: Run ruff lints
27-
entry: poetry run ruff
40+
entry: uv run ruff
2841
language: system
2942
pass_filenames: false
3043
types: [python]
@@ -36,10 +49,10 @@ repos:
3649

3750
- id: mypy
3851
name: Validate types with MyPy
39-
entry: poetry run mypy
52+
entry: uv run mypy
4053
language: system
41-
types: [python]
4254
pass_filenames: false
55+
types: [python]
4356
args:
4457
- ./taskiq_aio_pika
4558
- ./tests

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2024 Pavel Kirilin
3+
Copyright (c) 2022-2025 Pavel Kirilin
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# AioPika broker for taskiq
22

3+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/taskiq-aio-pika?style=for-the-badge)](https://pypi.org/project/taskiq-aio-pika/)
4+
[![PyPI](https://img.shields.io/pypi/v/taskiq-aio-pika?style=for-the-badge)](https://pypi.org/project/taskiq-aio-pika/)
5+
[![PyPI - Downloads](https://img.shields.io/pypi/dm/taskiq-aio-pika?style=for-the-badge)](https://pypistats.org/packages/taskiq-aio-pika)
6+
37
This library provides you with aio-pika broker for taskiq.
48

5-
Usage:
9+
Features:
10+
- Supports delayed messages using dead-letter queues or RabbitMQ delayed message exchange plugin.
11+
- Supports message priorities.
12+
13+
Usage example:
14+
615
```python
716
from taskiq_aio_pika import AioPikaBroker
817

@@ -14,19 +23,13 @@ async def test() -> None:
1423

1524
```
1625

17-
## Non-obvious things
18-
19-
You can send delayed messages and set priorities to messages using labels.
20-
2126
## Delays
2227

23-
### **Default retries**
28+
### Default delays
2429

25-
To send delayed message, you have to specify
26-
delay label. You can do it with `task` decorator,
27-
or by using kicker.
28-
In this type of delay we are using additional queue with `expiration` parameter and after with time message will be deleted from `delay` queue and sent to the main taskiq queue.
29-
For example:
30+
To send delayed message, you have to specify delay label. You can do it with `task` decorator, or by using kicker.
31+
32+
In this type of delay we are using additional queue with `expiration` parameter. After declared time message will be deleted from `delay` queue and sent to the main queue. For example:
3033

3134
```python
3235
broker = AioPikaBroker()
@@ -42,7 +45,7 @@ async def main():
4245
await delayed_task.kiq()
4346

4447
# This message is going to be received after the delay in 4 seconds.
45-
# Since we overriden the `delay` label using kicker.
48+
# Since we overridden the `delay` label using kicker.
4649
await delayed_task.kicker().with_labels(delay=4).kiq()
4750

4851
# This message is going to be send immediately. Since we deleted the label.
@@ -52,16 +55,13 @@ async def main():
5255
# have to wait delay period before message is going to be sent.
5356
```
5457

55-
### **Retries with `rabbitmq-delayed-message-exchange` plugin**
58+
### Delays with `rabbitmq-delayed-message-exchange` plugin
5659

57-
To send delayed message you can install `rabbitmq-delayed-message-exchange`
58-
plugin https://github.com/rabbitmq/rabbitmq-delayed-message-exchange.
60+
First of all please make sure that your RabbitMQ server has [rabbitmq-delayed-message-exchange plugin](https://github.com/rabbitmq/rabbitmq-delayed-message-exchange) installed.
5961

60-
And you need to configure you broker.
61-
There is `delayed_message_exchange_plugin` `AioPikaBroker` parameter and it must be `True` to turn on delayed message functionality.
62+
Also you need to configure you broker by passing `delayed_message_exchange_plugin=True` to broker.
6263

63-
The delay plugin can handle tasks with different delay times well, and the delay based on dead letter queue is suitable for tasks with the same delay time.
64-
For example:
64+
This plugin can handle tasks with different delay times well, and the delay based on dead letter queue is suitable for tasks with the same delay time. For example:
6565

6666
```python
6767
broker = AioPikaBroker(
@@ -79,22 +79,18 @@ async def main():
7979
await delayed_task.kiq()
8080

8181
# This message is going to be received after the delay in 4 seconds.
82-
# Since we overriden the `delay` label using kicker.
82+
# Since we overridden the `delay` label using kicker.
8383
await delayed_task.kicker().with_labels(delay=4).kiq()
8484
```
8585

8686
## Priorities
8787

88-
You can define priorities for messages using `priority` label.
89-
Messages with higher priorities are delivered faster.
90-
But to use priorities you need to define `max_priority` of the main queue, by passing `max_priority` parameter in broker's init.
91-
This parameter sets maximum priority for the queue and
92-
declares it as the prority queue.
88+
You can define priorities for messages using `priority` label. Messages with higher priorities are delivered faster.
89+
But to use priorities you need to define `max_priority` of the main queue, by passing `max_priority` parameter in broker's init. This parameter sets maximum priority for the queue and declares it as the priority queue.
9390

9491
Before doing so please read the [documentation](https://www.rabbitmq.com/priority.html#behaviour) about what
9592
downsides you get by using prioritized queues.
9693

97-
9894
```python
9995
broker = AioPikaBroker(max_priority=10)
10096

@@ -113,12 +109,12 @@ async def main():
113109

114110
# This message is going to have priority 0.
115111
await prio_task.kicker().with_labels(priority=None).kiq()
116-
117112
```
118113

119114
## Configuration
120115

121116
AioPikaBroker parameters:
117+
122118
* `url` - url to rabbitmq. If None, "amqp://guest:guest@localhost:5672" is used.
123119
* `result_backend` - custom result backend.
124120
* `task_id_generator` - custom task_id genertaor.
@@ -128,22 +124,19 @@ AioPikaBroker parameters:
128124
* `routing_key` - that used to bind that queue to the exchange.
129125
* `declare_exchange` - whether you want to declare new exchange if it doesn't exist.
130126
* `max_priority` - maximum priority for messages.
131-
* `delay_queue_name` - custom delay queue name.
132-
This queue is used to deliver messages with delays.
127+
* `delay_queue_name` - custom delay queue name. This queue is used to deliver messages with delays.
133128
* `dead_letter_queue_name` - custom dead letter queue name.
134-
This queue is used to receive negatively acknowleged messages from the main queue.
129+
This queue is used to receive negatively acknowledged messages from the main queue.
135130
* `qos` - number of messages that worker can prefetch.
136-
* `declare_queues` - whether you want to declare queues even on
137-
client side. May be useful for message persistance.
131+
* `declare_queues` - whether you want to declare queues even on client side. May be useful for message persistence.
138132
* `declare_queues_kwargs` - see [Custom Queue Arguments](#custom-queue-arguments) for more details.
139133

140134
## Custom Queue Arguments
141135

142136
You can pass custom arguments to the underlying RabbitMQ queue declaration by using the `declare_queues_kwargs` parameter of `AioPikaBroker`. If you want to set specific queue arguments (such as RabbitMQ extensions or custom behaviors), provide them in the `arguments` dictionary inside `declare_queues_kwargs`.
143137

144-
These arguments will be merged with the default arguments used by the broker (such as dead-lettering and priority settings).
145-
146-
**Example:**
138+
These arguments will be merged with the default arguments used by the broker
139+
(such as dead-lettering and priority settings). If there are any conflicts, the values you provide will take precedence over the broker's defaults. Example:
147140

148141
```python
149142
broker = AioPikaBroker(

docker-compose.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
rabbitmq:
3+
container_name: taskiq_aio_pika_rabbitmq
4+
image: heidiks/rabbitmq-delayed-message-exchange:latest
5+
environment:
6+
RABBITMQ_DEFAULT_USER: "guest"
7+
RABBITMQ_DEFAULT_PASS: "guest"
8+
RABBITMQ_DEFAULT_VHOST: "/"
9+
healthcheck:
10+
test: ["CMD", "rabbitmq-diagnostics", "check_running", "-q"]
11+
interval: 10s
12+
timeout: 5s
13+
retries: 8
14+
ports:
15+
- "5672:5672"
16+
- "15672:15672"
17+
- "61613:61613"

0 commit comments

Comments
 (0)