Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
github-actions:
patterns:
- "*"
# Python
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
groups:
pip:
patterns:
- "*"
53 changes: 37 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches:
- master
pull_request:
types: [opened, synchronize]
types:
- opened
- synchronize
- ready_for_review

jobs:
static_analysis:
Expand All @@ -16,31 +19,36 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Dependencies and library
shell: bash
run: |
set -ux
python -m pip install --upgrade pip
pip install -e ".[dev]"

- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-static-analysis-${{ hashFiles('pyproject.toml') }}-test-v03
- uses: astral-sh/setup-uv@v6
if: steps.cache.outputs.cache-hit != 'true'
with:
version: "latest"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: uv pip install --system ".[dev]"

- name: Run formatter
shell: bash
run: ruff format taskiq_faststream

- name: Run ruff
shell: bash
run: ruff check taskiq_faststream
- name: Run mypy
shell: bash
run: mypy taskiq_faststream

- name: Run ruff
shell: bash
run: ruff taskiq_faststream

test:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false

steps:
Expand All @@ -49,14 +57,20 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
- uses: astral-sh/setup-uv@v6
if: steps.cache.outputs.cache-hit != 'true'
with:
version: "latest"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -e .[test]
run: uv pip install --system ".[test]"

- run: mkdir coverage
- name: Test
run: bash scripts/test.sh
Expand All @@ -69,6 +83,7 @@ jobs:
name: .coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
path: coverage
if-no-files-found: error
include-hidden-files: true

coverage-combine:
needs: [test]
Expand All @@ -79,7 +94,11 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: 3.9

- uses: astral-sh/setup-uv@v6
with:
version: "latest"

- name: Get coverage files
uses: actions/download-artifact@v4
Expand All @@ -88,7 +107,7 @@ jobs:
path: coverage
merge-multiple: true

- run: pip install coverage[toml]
- run: uv pip install --system "coverage[toml]"

- run: ls -la coverage
- run: coverage combine coverage
Expand All @@ -100,6 +119,8 @@ jobs:
with:
name: coverage-html
path: htmlcov
if-no-files-found: error
include-hidden-files: true

# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
uv.lock

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -143,6 +145,8 @@ venv.bak/
.dmypy.json
dmypy.json

.ruff_cache/

# Pyre type checker
.pyre/

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pip install taskiq-faststream[rabbit]
pip install taskiq-faststream[kafka]
# or
pip install taskiq-faststream[nats]
# or
pip install taskiq-faststream[redis]
```

## Usage
Expand Down
29 changes: 14 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ authors = [

keywords = ["taskiq", "tasks", "distributed", "async", "FastStream"]

requires-python = ">=3.8"
requires-python = ">=3.9"

classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries",
Expand Down Expand Up @@ -81,10 +81,9 @@ test = [

dev = [
"taskiq-faststream[test]",

"mypy>=1.8.0,<1.12.0",
"ruff==0.4.1",
"pre-commit >=3.6.0,<4.0.0",
"mypy==1.11.2",
"ruff==0.11.8",
"pre-commit >=3.6.0,<5.0.0",
]

[project.urls]
Expand All @@ -107,7 +106,7 @@ exclude = [
]

[tool.mypy]
python_version = "3.8"
python_version = "3.9"
strict = true
ignore_missing_imports = true
allow_subclassing_any = true
Expand All @@ -125,12 +124,14 @@ known_third_party = ["faststream", "taskiq"]

[tool.ruff]
fix = true
target-version = "py38"
target-version = "py39"
line-length = 88
mccabe = { max-complexity = 10 }

[tool.ruff.lint]
# List of enabled rulsets.
# See https://docs.astral.sh/ruff/rules/ for more information.
mccabe = { max-complexity = 10 }

select = [
"E", # Error
"F", # Pyflakes
Expand Down Expand Up @@ -167,8 +168,6 @@ ignore = [
"D401", # First line should be in imperative mood
"D104", # Missing docstring in public package
"D100", # Missing docstring in public module
"ANN102", # Missing type annotation for self in method
"ANN101", # Missing type annotation for argument
"ANN401", # typing.Any are disallowed in `**kwargs
"PLR0913", # Too many arguments for function call
"D106", # Missing docstring in public nested class
Expand All @@ -177,7 +176,7 @@ ignore = [
]
exclude = [".venv/"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"S101", # Use of assert detected
"S301", # Use of pickle detected
Expand All @@ -187,14 +186,14 @@ exclude = [".venv/"]
"D101", # Missing docstring in public class
]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"
ignore-decorators = ["typing.overload"]

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
allow-magic-value-types = ["int", "str", "float"]

[tool.ruff.flake8-bugbear]
[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = []

[tool.pytest.ini_options]
Expand Down
6 changes: 3 additions & 3 deletions scripts/lint.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

echo "Running ruff..."
ruff taskiq_faststream tests --fix

echo "Running ruff formatter..."
ruff format taskiq_faststream tests

echo "Running ruff..."
ruff check taskiq_faststream tests --fix

echo "Running mypy..."
mypy taskiq_faststream
2 changes: 1 addition & 1 deletion taskiq_faststream/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""FastStream - taskiq integration to schedule FastStream tasks."""

__version__ = "0.2.0"
__version__ = "0.2.1"
2 changes: 1 addition & 1 deletion taskiq_faststream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from taskiq_faststream.scheduler import StreamScheduler

__all__ = (
"AppWrapper",
"BrokerWrapper",
"StreamScheduler",
"AppWrapper",
)
9 changes: 4 additions & 5 deletions taskiq_faststream/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from typing import Any

import anyio
from faststream.app import FastStream
from faststream._internal.application import Application
from faststream.types import SendableMessage
from taskiq import AsyncBroker
from taskiq.acks import AckableMessage
from taskiq.decor import AsyncTaskiqDecoratedTask
from typing_extensions import TypeAlias, override
from typing_extensions import TypeAlias

from taskiq_faststream.formatter import PatchedFormatter, PathcedMessage
from taskiq_faststream.types import ScheduledTask
Expand Down Expand Up @@ -66,7 +66,6 @@ async def listen(
yield b""
await anyio.sleep(60)

@override
def task( # type: ignore[override]
self,
message: typing.Union[
Expand All @@ -76,7 +75,7 @@ def task( # type: ignore[override]
typing.Callable[[], typing.Awaitable[SendableMessage]],
] = None,
*,
schedule: typing.List[ScheduledTask],
schedule: list[ScheduledTask],
**kwargs: PublishParameters,
) -> "AsyncTaskiqDecoratedTask[[], None]":
"""Register FastStream scheduled task.
Expand Down Expand Up @@ -107,7 +106,7 @@ class AppWrapper(BrokerWrapper):
task : Register FastStream scheduled task.
"""

def __init__(self, app: FastStream) -> None:
def __init__(self, app: Application) -> None:
super(BrokerWrapper, self).__init__()
self.formatter = PatchedFormatter()
self.app = app
Expand Down
4 changes: 2 additions & 2 deletions taskiq_faststream/formatter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any, Dict
from typing import Any

from taskiq.abc.formatter import TaskiqFormatter
from taskiq.message import TaskiqMessage
Expand All @@ -10,7 +10,7 @@ class PathcedMessage:
"""DTO to transfer data to `broker.kick`."""

body: Any
labels: Dict[str, Any]
labels: dict[str, Any]


class PatchedFormatter(TaskiqFormatter):
Expand Down
Empty file added taskiq_faststream/py.typed
Empty file.
7 changes: 7 additions & 0 deletions tests/test_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ class TestApp(TestBroker):
def build_taskiq_broker(broker: KafkaBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker))


class TestAsgiApp(TestBroker):
@staticmethod
def build_taskiq_broker(broker: KafkaBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker).as_asgi())
7 changes: 7 additions & 0 deletions tests/test_nats.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ class TestApp(TestBroker):
def build_taskiq_broker(broker: NatsBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker))


class TestAsgiApp(TestBroker):
@staticmethod
def build_taskiq_broker(broker: NatsBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker).as_asgi())
7 changes: 7 additions & 0 deletions tests/test_rabbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ class TestApp(TestBroker):
def build_taskiq_broker(broker: RabbitBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker))


class TestAsgiApp(TestBroker):
@staticmethod
def build_taskiq_broker(broker: RabbitBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker).as_asgi())
7 changes: 7 additions & 0 deletions tests/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ class TestApp(TestBroker):
def build_taskiq_broker(broker: RedisBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker))


class TestAsgiApp(TestBroker):
@staticmethod
def build_taskiq_broker(broker: RedisBroker) -> AsyncBroker:
"""Build AppWrapper."""
return AppWrapper(FastStream(broker).as_asgi())
2 changes: 1 addition & 1 deletion tests/test_resolve_message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import AsyncIterator, Iterator
from collections.abc import AsyncIterator, Iterator

import pytest

Expand Down
Loading
Loading