Skip to content

Commit 9868d65

Browse files
authored
Merge branch 'develop' into dependabot/github_actions/pypa/gh-action-pypi-publish-1.9.0
2 parents b0d6c15 + 43b3255 commit 9868d65

File tree

14 files changed

+97
-57
lines changed

14 files changed

+97
-57
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ updates:
1010
directory: "/"
1111
schedule:
1212
interval: "weekly"
13+
groups:
14+
github-actions:
15+
patterns:
16+
- "*"
1317
# Python
1418
- package-ecosystem: "pip" # See documentation for possible values
1519
directory: "/" # Location of package manifests
1620
schedule:
1721
interval: "weekly"
22+
groups:
23+
pip:
24+
patterns:
25+
- "*"

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
runs-on: ubuntu-latest
4141
strategy:
4242
matrix:
43-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
43+
python-version: ["3.9", "3.10", "3.11", "3.12, "3.13"]
4444
fail-fast: false
4545

4646
steps:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
uv.lock
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
*.py[cod]
@@ -143,6 +145,8 @@ venv.bak/
143145
.dmypy.json
144146
dmypy.json
145147

148+
.ruff_cache/
149+
146150
# Pyre type checker
147151
.pyre/
148152

pyproject.toml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ authors = [
1313

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

16-
requires-python = ">=3.8"
16+
requires-python = ">=3.9"
1717

1818
classifiers = [
1919
"Development Status :: 5 - Production/Stable",
2020
"License :: OSI Approved :: MIT License",
2121
"Programming Language :: Python",
2222
"Programming Language :: Python :: 3",
2323
"Programming Language :: Python :: 3 :: Only",
24-
"Programming Language :: Python :: 3.8",
2524
"Programming Language :: Python :: 3.9",
2625
"Programming Language :: Python :: 3.10",
2726
"Programming Language :: Python :: 3.11",
2827
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
2929
"Operating System :: OS Independent",
3030
"Topic :: Software Development :: Libraries :: Python Modules",
3131
"Topic :: Software Development :: Libraries",
@@ -42,7 +42,7 @@ classifiers = [
4242
dynamic = ["version"]
4343

4444
dependencies = [
45-
"taskiq>=0.10.0,<1.0.0",
45+
"taskiq>=0.11.0,<0.12.0",
4646
"faststream>=0.3.14,<0.6.0",
4747
]
4848

@@ -59,6 +59,10 @@ kafka = [
5959
"faststream[kafka]"
6060
]
6161

62+
confluent = [
63+
"faststream[confluent]"
64+
]
65+
6266
redis = [
6367
"faststream[redis]"
6468
]
@@ -68,6 +72,7 @@ test = [
6872
"taskiq-faststream[nats]",
6973
"taskiq-faststream[rabbit]",
7074
"taskiq-faststream[kafka]",
75+
"taskiq-faststream[confluent]",
7176
"taskiq-faststream[redis]",
7277

7378
"coverage[toml]>=7.2.0,<8.0.0",
@@ -77,9 +82,9 @@ test = [
7782
dev = [
7883
"taskiq-faststream[test]",
7984

80-
"mypy>=1.8.0,<1.10.0",
81-
"ruff==0.4.1",
82-
"pre-commit >=3.6.0,<4.0.0",
85+
"mypy>=1.8.0,<1.16.0",
86+
"ruff==0.11.8",
87+
"pre-commit >=3.6.0,<5.0.0",
8388
]
8489

8590
[project.urls]
@@ -102,7 +107,7 @@ exclude = [
102107
]
103108

104109
[tool.mypy]
105-
python_version = "3.8"
110+
python_version = "3.9"
106111
strict = true
107112
ignore_missing_imports = true
108113
allow_subclassing_any = true
@@ -120,12 +125,14 @@ known_third_party = ["faststream", "taskiq"]
120125

121126
[tool.ruff]
122127
fix = true
123-
target-version = "py38"
128+
target-version = "py39"
124129
line-length = 88
125-
mccabe = { max-complexity = 10 }
126130

131+
[tool.ruff.lint]
127132
# List of enabled rulsets.
128133
# See https://docs.astral.sh/ruff/rules/ for more information.
134+
mccabe = { max-complexity = 10 }
135+
129136
select = [
130137
"E", # Error
131138
"F", # Pyflakes
@@ -162,8 +169,6 @@ ignore = [
162169
"D401", # First line should be in imperative mood
163170
"D104", # Missing docstring in public package
164171
"D100", # Missing docstring in public module
165-
"ANN102", # Missing type annotation for self in method
166-
"ANN101", # Missing type annotation for argument
167172
"ANN401", # typing.Any are disallowed in `**kwargs
168173
"PLR0913", # Too many arguments for function call
169174
"D106", # Missing docstring in public nested class
@@ -172,7 +177,7 @@ ignore = [
172177
]
173178
exclude = [".venv/"]
174179

175-
[tool.ruff.per-file-ignores]
180+
[tool.ruff.lint.per-file-ignores]
176181
"tests/*" = [
177182
"S101", # Use of assert detected
178183
"S301", # Use of pickle detected
@@ -182,14 +187,14 @@ exclude = [".venv/"]
182187
"D101", # Missing docstring in public class
183188
]
184189

185-
[tool.ruff.pydocstyle]
190+
[tool.ruff.lint.pydocstyle]
186191
convention = "google"
187192
ignore-decorators = ["typing.overload"]
188193

189-
[tool.ruff.pylint]
194+
[tool.ruff.lint.pylint]
190195
allow-magic-value-types = ["int", "str", "float"]
191196

192-
[tool.ruff.flake8-bugbear]
197+
[tool.ruff.lint.flake8-bugbear]
193198
extend-immutable-calls = []
194199

195200
[tool.pytest.ini_options]

scripts/lint.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
echo "Running ruff..."
4-
ruff taskiq_faststream tests --fix
4+
ruff check taskiq_faststream tests --fix
55

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

taskiq_faststream/__about__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
"""FastStream - taskiq integration to schedule FastStream tasks."""
2-
__version__ = "0.1.8"
2+
3+
__version__ = "0.2.1"

taskiq_faststream/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from taskiq_faststream.scheduler import StreamScheduler
33

44
__all__ = (
5+
"AppWrapper",
56
"BrokerWrapper",
67
"StreamScheduler",
7-
"AppWrapper",
88
)

taskiq_faststream/broker.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import anyio
66
from faststream.app import FastStream
77
from faststream.types import SendableMessage
8-
from taskiq import AsyncBroker, BrokerMessage
8+
from taskiq import AsyncBroker
99
from taskiq.acks import AckableMessage
1010
from taskiq.decor import AsyncTaskiqDecoratedTask
11-
from typing_extensions import TypeAlias, override
11+
from typing_extensions import TypeAlias
1212

13-
from taskiq_faststream.serializer import PatchedSerializer
13+
from taskiq_faststream.formatter import PatchedFormatter, PathcedMessage
1414
from taskiq_faststream.types import ScheduledTask
1515
from taskiq_faststream.utils import resolve_msg
1616

@@ -33,7 +33,7 @@ class BrokerWrapper(AsyncBroker):
3333

3434
def __init__(self, broker: Any) -> None:
3535
super().__init__()
36-
self.serializer = PatchedSerializer()
36+
self.formatter = PatchedFormatter()
3737
self.broker = broker
3838

3939
async def startup(self) -> None:
@@ -46,7 +46,7 @@ async def shutdown(self) -> None:
4646
await self.broker.close()
4747
await super().shutdown()
4848

49-
async def kick(self, message: BrokerMessage) -> None:
49+
async def kick(self, message: PathcedMessage) -> None: # type: ignore[override]
5050
"""Call wrapped FastStream broker `publish` method."""
5151
await _broker_publish(self.broker, message)
5252

@@ -66,8 +66,7 @@ async def listen(
6666
yield b""
6767
await anyio.sleep(60)
6868

69-
@override
70-
def task( # type: ignore[override]
69+
def task(
7170
self,
7271
message: typing.Union[
7372
None,
@@ -76,7 +75,7 @@ def task( # type: ignore[override]
7675
typing.Callable[[], typing.Awaitable[SendableMessage]],
7776
] = None,
7877
*,
79-
schedule: typing.List[ScheduledTask],
78+
schedule: list[ScheduledTask],
8079
**kwargs: PublishParameters,
8180
) -> "AsyncTaskiqDecoratedTask[[], None]":
8281
"""Register FastStream scheduled task.
@@ -109,7 +108,7 @@ class AppWrapper(BrokerWrapper):
109108

110109
def __init__(self, app: FastStream) -> None:
111110
super(BrokerWrapper, self).__init__()
112-
self.serializer = PatchedSerializer()
111+
self.formatter = PatchedFormatter()
113112
self.app = app
114113

115114
async def startup(self) -> None:
@@ -122,7 +121,7 @@ async def shutdown(self) -> None:
122121
await self.app._shutdown() # noqa: SLF001
123122
await super(BrokerWrapper, self).shutdown()
124123

125-
async def kick(self, message: BrokerMessage) -> None:
124+
async def kick(self, message: PathcedMessage) -> None: # type: ignore[override]
126125
"""Call wrapped FastStream broker `publish` method."""
127126
assert ( # noqa: S101
128127
self.app.broker
@@ -132,11 +131,7 @@ async def kick(self, message: BrokerMessage) -> None:
132131

133132
async def _broker_publish(
134133
broker: Any,
135-
message: BrokerMessage,
134+
message: PathcedMessage,
136135
) -> None:
137-
labels = message.labels
138-
labels.pop("schedule", None)
139-
async for msg in resolve_msg(
140-
msg=labels.pop("message", message.message),
141-
):
142-
await broker.publish(msg, **labels)
136+
async for msg in resolve_msg(message.body):
137+
await broker.publish(msg, **message.labels)

taskiq_faststream/formatter.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from dataclasses import dataclass
2+
from typing import Any
3+
4+
from taskiq.abc.formatter import TaskiqFormatter
5+
from taskiq.message import TaskiqMessage
6+
7+
8+
@dataclass
9+
class PathcedMessage:
10+
"""DTO to transfer data to `broker.kick`."""
11+
12+
body: Any
13+
labels: dict[str, Any]
14+
15+
16+
class PatchedFormatter(TaskiqFormatter):
17+
"""Default taskiq formatter."""
18+
19+
def dumps( # type: ignore[override]
20+
self,
21+
message: TaskiqMessage,
22+
) -> PathcedMessage:
23+
"""
24+
Dumps taskiq message to some broker message format.
25+
26+
:param message: message to send.
27+
:return: Dumped message.
28+
"""
29+
labels = message.labels
30+
labels.pop("schedule", None)
31+
labels.pop("schedule_id", None)
32+
33+
return PathcedMessage(
34+
body=labels.pop("message", None),
35+
labels=labels,
36+
)
37+
38+
def loads(self, message: bytes) -> TaskiqMessage:
39+
"""
40+
Loads json from message.
41+
42+
:param message: broker's message.
43+
:return: parsed taskiq message.
44+
"""
45+
raise NotImplementedError

taskiq_faststream/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)