modern-di integration for aiogram
Project description
modern-di-aiogram
Modern-DI integration for aiogram 3.x.
Quickstart
import typing
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from modern_di import Container, Group, Scope, providers
from modern_di_aiogram import FromDI, inject, setup_di
class Settings:
def __init__(self) -> None:
self.greeting = "hello"
class Dependencies(Group):
settings = providers.Factory(scope=Scope.APP, creator=Settings)
dispatcher = Dispatcher()
setup_di(dispatcher, Container(groups=[Dependencies], validate=True))
@dispatcher.message()
@inject
async def greet(message: Message, settings: typing.Annotated[Settings, FromDI(Dependencies.settings)]) -> None:
await message.answer(f"{settings.greeting}, {message.from_user.first_name}")
See the documentation for the full guide, including auto_inject.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modern_di_aiogram-2.0.0.tar.gz.
File metadata
- Download URL: modern_di_aiogram-2.0.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba09377a5c3e505b6f33f53f1e197e74b604287afe132a39f4835b81e70e5599
|
|
| MD5 |
b2446f958dc1079134710612300e3f88
|
|
| BLAKE2b-256 |
648e20c4419fcc62e683a39b38053c5b07d71188988fa9e54bea532c1108e331
|
File details
Details for the file modern_di_aiogram-2.0.0-py3-none-any.whl.
File metadata
- Download URL: modern_di_aiogram-2.0.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33b5169e79aaced63faa483fc3bd66ad77c17bd403c9c7717c30ce2ca9729dad
|
|
| MD5 |
c63eef8adaa786016b2b9e147bad451a
|
|
| BLAKE2b-256 |
757bbc1eb28f58bf811a733adbb035e8b2b25d9e5dd3ebf018a74d714ea7b229
|