feat: aiogram-dialog DI support (modern_di_aiogram.dialog)#1
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Final-review cleanups: remove an unused _TOKEN constant from the dialog test, and document that a FromDI getter param must not collide with a middleware_data key (getters are called as getter(**middleware_data)). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
modern_di_aiogram.dialogsubmodule with a dialog-aware@injectfor aiogram-dialog getters and callbacks. Ships as 2.1.0 (minor, backward-compatible).What
aiogram-dialog runs inside aiogram's dispatch, so
setup_di's middleware already builds the per-updateScope.REQUESTchild indata["modern_di_container"]. The newdialog.injectfinds that child by call shape — getter → kwargs; callbacks carry aDialogManagerpositionally (args[-1]for 2-arg on_start/on_close,args[2]for 3–4-arg on_click/on_process_result) →manager.middleware_data[...]— and resolvesFromDI.FromDImarker, and child-key frommodern_di_aiogram.main—main.py/__init__.pyuntouched (purely additive)..middleware_data);aiogram-dialog>=2,<3is a test dep only.from modern_di_aiogram.dialog import inject, FromDI.Tests
tests/test_dialog.pydrives a real two-dialog flow bot-less viaaiogram_dialog.test_tools(BotClient/MockMessageManager), covering all four callback shapes (getter, on_start, on_click, on_process_result) + passthrough + per-update child close. 100% coverage; ruff/ty/eof clean.Reviewed per-task + whole-branch on the most capable model; the dispatch was verified against the installed aiogram-dialog source.
🤖 Generated with Claude Code