Skip to content

Commit 38e92f6

Browse files
committed
Merge branch 'release/0.1.3'
2 parents 76da3b7 + 94df90f commit 38e92f6

31 files changed

+449
-947
lines changed

docs/guide/state-and-deps.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ You can access the state from the context.
3737

3838
## Dependencies
3939

40-
Using context directly is nice, but this way won't get completion.
40+
Using context directly is nice, but this way you won't get code-completion.
4141

4242
That's why we suggest you try TaskiqDependencies. The implementation is very similar to FastApi's dependencies. You can use classes, functions, and generators as dependencies.
4343

44+
We use the [taskiq-dependencies](https://pypi.org/project/taskiq-dependencies/) package to provide autocompetion.
45+
You can easily integrate it in your own project.
46+
4447
::: danger Cool alarm!
4548

4649
FastAPI's `Depends` is not compatible with `TaskiqDepends`.

poetry.lock

Lines changed: 197 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "taskiq"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "Distributed task queue with full async support"
55
authors = ["Pavel Kirilin <[email protected]>"]
66
maintainers = ["Pavel Kirilin <[email protected]>"]
@@ -54,6 +54,7 @@ mock = "^4.0.3"
5454
anyio = "^3.6.1"
5555
pytest-xdist = { version = "^2.5.0", extras = ["psutil"] }
5656
types-mock = "^4.0.15"
57+
taskiq_dependencies = "~1.0.0"
5758

5859
[tool.poetry.extras]
5960
zmq = ["pyzmq"]
@@ -82,6 +83,18 @@ warn_unused_ignores = false
8283
profile = "black"
8384
multi_line_output = 3
8485

86+
[tool.coverage.run]
87+
omit = [
88+
"taskiq/__main__.py",
89+
"taskiq/abc/cmd.py",
90+
"taskiq/cli/scheduler/args.py",
91+
"taskiq/cli/scheduler/cmd.py",
92+
"taskiq/cli/utils.py",
93+
"taskiq/cli/worker/args.py",
94+
"taskiq/cli/worker/async_task_runner.py",
95+
"taskiq/cli/worker/cmd.py",
96+
]
97+
8598
[build-system]
8699
requires = ["poetry-core>=1.0.0"]
87100
build-backend = "poetry.core.masonry.api"

taskiq/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Distributed task manager."""
2+
from taskiq_dependencies import Depends as TaskiqDepends
3+
24
from taskiq.abc.broker import AsyncBroker, AsyncTaskiqDecoratedTask
35
from taskiq.abc.formatter import TaskiqFormatter
46
from taskiq.abc.middleware import TaskiqMiddleware
@@ -8,7 +10,6 @@
810
from taskiq.brokers.shared_broker import async_shared_broker
911
from taskiq.brokers.zmq_broker import ZeroMQBroker
1012
from taskiq.context import Context
11-
from taskiq.dependencies import TaskiqDepends
1213
from taskiq.events import TaskiqEvents
1314
from taskiq.exceptions import TaskiqError
1415
from taskiq.funcs import gather

taskiq/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from taskiq.abc.cmd import TaskiqCMD
88

99

10-
def main() -> None: # noqa: C901, WPS210
10+
def main() -> None: # noqa: C901, WPS210 # pragma: no cover
1111
"""
1212
Main entrypoint of the taskiq.
1313
@@ -72,5 +72,5 @@ def main() -> None: # noqa: C901, WPS210
7272
command.exec(sys.argv[1:])
7373

7474

75-
if __name__ == "__main__":
75+
if __name__ == "__main__": # pragma: no cover
7676
main()

taskiq/abc/broker.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,15 @@ async def listen(
167167
def task(
168168
self,
169169
task_name: Callable[_FuncParams, _ReturnType],
170+
**lavels: Any,
170171
) -> AsyncTaskiqDecoratedTask[_FuncParams, _ReturnType]: # pragma: no cover
171172
...
172173

173174
@overload
174175
def task(
175176
self,
176177
task_name: Optional[str] = None,
177-
**labels: Union[str, int],
178+
**labels: Any,
178179
) -> Callable[
179180
[Callable[_FuncParams, _ReturnType]],
180181
AsyncTaskiqDecoratedTask[_FuncParams, _ReturnType],
@@ -184,7 +185,7 @@ def task(
184185
def task( # type: ignore[misc]
185186
self,
186187
task_name: Optional[str] = None,
187-
**labels: Union[str, int],
188+
**labels: Any,
188189
) -> Any:
189190
"""
190191
Decorator that turns function into a task.
@@ -223,7 +224,7 @@ def inner(
223224
if inner_task_name is None:
224225
fmodule = func.__module__
225226
if fmodule == "__main__": # pragma: no cover
226-
fmodule = ".".join( # noqa: WPS220
227+
fmodule = ".".join(
227228
sys.argv[0]
228229
.removesuffix(
229230
".py",

taskiq/abc/cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Sequence
33

44

5-
class TaskiqCMD(ABC):
5+
class TaskiqCMD(ABC): # pragma: no cover
66
"""Base class for new commands."""
77

88
short_help = ""

taskiq/abc/schedule_source.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
class ScheduleSource(ABC):
99
"""Abstract class for source of scheduled tasks."""
1010

11-
async def startup(self) -> None:
11+
async def startup(self) -> None: # noqa: B027
1212
"""Action to execute during startup."""
1313

14-
async def shutdown(self) -> None:
14+
async def shutdown(self) -> None: # noqa: B027
1515
"""Actions to execute during shutdown."""
1616

1717
@abstractmethod
1818
async def get_schedules(self) -> List["ScheduledTask"]:
1919
"""Get list of taskiq schedules."""
2020

21-
async def add_schedule(self, schedule: "ScheduledTask") -> None:
21+
async def add_schedule(self, schedule: "ScheduledTask") -> None: # noqa: B027
2222
"""
2323
Add a new schedule.
2424

taskiq/brokers/inmemory_broker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
from collections import OrderedDict
33
from typing import Any, Callable, Coroutine, Optional, TypeVar, get_type_hints
44

5+
from taskiq_dependencies import DependencyGraph
6+
57
from taskiq.abc.broker import AsyncBroker
68
from taskiq.abc.result_backend import AsyncResultBackend, TaskiqResult
79
from taskiq.cli.worker.args import WorkerArgs
810
from taskiq.cli.worker.receiver import Receiver
9-
from taskiq.dependencies import DependencyGraph
1011
from taskiq.events import TaskiqEvents
1112
from taskiq.exceptions import TaskiqError
1213
from taskiq.message import BrokerMessage

taskiq/cli/worker/receiver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
from time import time
77
from typing import Any, Callable, Dict, get_type_hints
88

9+
from taskiq_dependencies import DependencyGraph
10+
911
from taskiq.abc.broker import AsyncBroker
1012
from taskiq.abc.middleware import TaskiqMiddleware
1113
from taskiq.cli.worker.args import WorkerArgs
1214
from taskiq.cli.worker.log_collector import log_collector
1315
from taskiq.cli.worker.params_parser import parse_params
1416
from taskiq.context import Context
15-
from taskiq.dependencies import DependencyGraph
1617
from taskiq.message import BrokerMessage, TaskiqMessage
1718
from taskiq.result import TaskiqResult
1819
from taskiq.state import TaskiqState
@@ -164,7 +165,7 @@ async def run_task( # noqa: C901, WPS210
164165
dep_ctx = None
165166
if dependency_graph:
166167
# Create a context for dependency resolving.
167-
dep_ctx = dependency_graph.ctx(
168+
dep_ctx = dependency_graph.async_ctx(
168169
{
169170
Context: Context(message, self.broker),
170171
TaskiqState: self.broker.state,

0 commit comments

Comments
 (0)