From 4a4b7e3d7e3fc934b349956f24c28276814c5ecd Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Mon, 5 Oct 2026 18:10:02 +0300 Subject: [PATCH] feat: support modern-di 4 Widen the requirement to modern-di>=3,<5. ADR 0002 now describes the 4.0 behaviour on a closed container, and the fetch_task_name test helper drops its unused None default. --- docs/adr/0002-only-worker-lifecycle-is-wired.md | 5 +++-- pyproject.toml | 2 +- tests/dependencies.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/adr/0002-only-worker-lifecycle-is-wired.md b/docs/adr/0002-only-worker-lifecycle-is-wired.md index 81ef93f..87df7e3 100644 --- a/docs/adr/0002-only-worker-lifecycle-is-wired.md +++ b/docs/adr/0002-only-worker-lifecycle-is-wired.md @@ -8,5 +8,6 @@ from them, then close them on a shutdown event a short-lived script often never documented in `README.md` rather than hidden: a process that both kicks and executes gets no lifecycle unless the worker events fire, which `InMemoryBroker.startup()` arranges by firing both pairs. `container.open()` on worker startup is unconditional and a no-op on a fresh container; it -earns its keep on a second worker cycle, reopening deliberately what the previous `WORKER_SHUTDOWN` -closed instead of leaving modern-di to reopen it implicitly with a `ContainerClosedWarning`. +earns its keep on a second worker cycle, reopening what the previous `WORKER_SHUTDOWN` closed. From +modern-di 4.0 a resolve from a closed container raises `ContainerClosedError`, so without this call +every task in the second cycle would fail. diff --git a/pyproject.toml b/pyproject.toml index af8f607..f1b9736 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers = [ "Typing :: Typed", "Topic :: Software Development :: Libraries", ] -dependencies = ["taskiq>=0.11,<0.13", "modern-di>=3,<4"] +dependencies = ["taskiq>=0.11,<0.13", "modern-di>=3,<5"] version = "0" [project.urls] diff --git a/tests/dependencies.py b/tests/dependencies.py index dca933b..0859d29 100644 --- a/tests/dependencies.py +++ b/tests/dependencies.py @@ -14,8 +14,8 @@ class DependentCreator: dep1: SimpleCreator -def fetch_task_name(message: taskiq.TaskiqMessage | None = None) -> str: - return message.task_name if message else "" +def fetch_task_name(message: taskiq.TaskiqMessage) -> str: + return message.task_name class Dependencies(Group):