Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.11"
- name: Install deps
run: poetry install
- name: Set version
run: poetry version "${GITHUB_REF_NAME}"
- name: Release package
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish --build
enable-cache: false
python-version: "3.12"
version: "latest"
- run: uv version "${GITHUB_REF_NAME}"
- run: uv build
- run: uv publish --trusted-publishing always
45 changes: 21 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,52 @@ jobs:
lint:
strategy:
matrix:
cmd:
- black
- ruff
- mypy
cmd: ["black", "ruff", "mypy"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v6
- id: setup-uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.11"
cache: "poetry"
enable-cache: true
cache-suffix: 3.11
version: "latest"
python-version: 3.11
- name: Install deps
run: poetry install --all-extras
run: uv sync --all-extras
- name: Run lint check
run: poetry run pre-commit run -a ${{ matrix.cmd }}
run: uv run pre-commit run -a ${{ matrix.cmd }}
pytest:
strategy:
matrix:
py_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
py_version: ["3.10", "3.11", "3.12", "3.13"]
pydantic_ver: ["<2", ">=2.5,<3"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: "${{ matrix.os }}"
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v6
- id: setup-uv
uses: astral-sh/setup-uv@v7
with:
python-version: "${{ matrix.py_version }}"
cache: "poetry"
enable-cache: true
cache-suffix: ${{ matrix.python-version }}
version: "latest"
python-version: ${{ matrix.python-version }}
- name: Install deps
run: poetry install --all-extras
run: uv sync --all-extras
- name: Setup pydantic version
run: poetry run pip install "pydantic ${{ matrix.pydantic_ver }}"
run: uv pip install "pydantic ${{ matrix.pydantic_ver }}"
- name: Run pytest check
run: poetry run pytest -vv -n auto --cov="taskiq" .
run: uv run pytest -vv -n auto --cov="taskiq" .
- name: Generate report
run: poetry run coverage xml
run: uv run coverage xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v5
if: matrix.os == 'ubuntu-latest' && matrix.py_version == '3.9'
if: matrix.os == 'ubuntu-latest' && matrix.py_version == '3.10'
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ repos:
hooks:
- id: black
name: Format with Black
entry: poetry run black
entry: uv run black
language: system
types: [python]

- id: ruff
name: Run ruff lints
entry: poetry run ruff
entry: uv run ruff
language: system
pass_filenames: false
types: [python]
Expand All @@ -51,7 +51,7 @@ repos:

- id: mypy
name: Validate types with MyPy
entry: poetry run mypy
entry: uv run mypy
language: system
pass_filenames: false
types: [python]
Expand Down
1 change: 0 additions & 1 deletion .python-version
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
3.12.8
3.11.11
3.10.16
3.9.21
4 changes: 2 additions & 2 deletions docs/contrib.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ We have lots of tests in CI. But since CI runs from first-time contributors shou

## Setting up environment

We use poetry for managing dependencies. To install it, please follow the official guide in [documentation](https://python-poetry.org/docs/).
We use uv for managing dependencies. To install it, please follow the official guide in [documentation](https://docs.astral.sh/uv/getting-started/installation/).

After you have cloned the taskiq repo, install dependencies using this command:

```bash
poetry install
uv sync
```

It will install all required dependencies.
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/extending/broker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import AsyncGenerator, Union
from collections.abc import AsyncGenerator

from taskiq import AckableMessage, AsyncBroker, BrokerMessage

Expand All @@ -23,7 +23,7 @@ async def kick(self, message: BrokerMessage) -> None:
# Send a message.message.
pass

async def listen(self) -> AsyncGenerator[Union[bytes, AckableMessage], None]:
async def listen(self) -> AsyncGenerator[bytes | AckableMessage, None]:
while True:
# Get new message.
new_message: bytes = ... # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/extending/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from argparse import ArgumentParser
from typing import Sequence
from collections.abc import Sequence

from taskiq.abc.cmd import TaskiqCMD

Expand Down
4 changes: 1 addition & 3 deletions docs/examples/extending/schedule_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

from taskiq import ScheduledTask, ScheduleSource


Expand All @@ -10,7 +8,7 @@ async def startup(self) -> None:
async def shutdown(self) -> None:
"""Do something on shutdown."""

async def get_schedules(self) -> List["ScheduledTask"]:
async def get_schedules(self) -> list["ScheduledTask"]:
# Here you must return list of scheduled tasks from your source.
return [
ScheduledTask(
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/schedule/intro.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from taskiq_aio_pika import AioPikaBroker

from taskiq.schedule_sources import LabelScheduleSource
from taskiq import TaskiqScheduler
from taskiq.schedule_sources import LabelScheduleSource

broker = AioPikaBroker("amqp://guest:guest@localhost:5672/")

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/schedule/redis_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
@broker.task
async def my_task(arg1: int, arg2: str) -> None:
"""Example task."""
print("Hello from my_task!", arg1, arg2) # noqa: T201
print("Hello from my_task!", arg1, arg2)
2 changes: 1 addition & 1 deletion docs/examples/state/async_generator_deps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
from typing import AsyncGenerator
from collections.abc import AsyncGenerator

from taskiq import TaskiqDepends

Expand Down
3 changes: 2 additions & 1 deletion docs/examples/state/async_generator_deps_annot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
from typing import Annotated, AsyncGenerator
from collections.abc import AsyncGenerator
from typing import Annotated

from taskiq import TaskiqDepends

Expand Down
3 changes: 1 addition & 2 deletions docs/examples/state/events_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
from typing import Optional

from redis.asyncio import ConnectionPool, Redis # type: ignore
from taskiq_aio_pika import AioPikaBroker
Expand Down Expand Up @@ -30,7 +29,7 @@ async def shutdown(state: TaskiqState) -> None:


@broker.task
async def get_val(key: str, context: Context = TaskiqDepends()) -> Optional[str]:
async def get_val(key: str, context: Context = TaskiqDepends()) -> str | None:
# Now we can use our pool.
redis = Redis(connection_pool=context.state.redis, decode_responses=True)
return await redis.get(key)
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/state/events_example_annot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
from typing import Annotated, Optional
from typing import Annotated

from redis.asyncio import ConnectionPool, Redis # type: ignore
from taskiq_aio_pika import AioPikaBroker
Expand Down Expand Up @@ -33,7 +33,7 @@ async def shutdown(state: TaskiqState) -> None:
async def get_val(
key: str,
context: Annotated[Context, TaskiqDepends()],
) -> Optional[str]:
) -> str | None:
# Now we can use our pool.
redis = Redis(connection_pool=context.state.redis, decode_responses=True)
return await redis.get(key)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/state/generator_deps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Generator
from collections.abc import Generator

from taskiq import TaskiqDepends

Expand Down
3 changes: 2 additions & 1 deletion docs/examples/state/generator_deps_annot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Annotated, Generator
from collections.abc import Generator
from typing import Annotated

from taskiq import TaskiqDepends

Expand Down
Loading
Loading