Metadata-Version: 2.4
Name: modern-di-aiogram
Version: 2.0.0
Summary: modern-di integration for aiogram
Keywords: dependency-injection,di,ioc-container,modern-di,aiogram,telegram,python
Author: Artur Shiriev
Author-email: Artur Shiriev <me@shiriev.ru>
License-Expression: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: aiogram>=3.2,<4
Requires-Dist: modern-di>=2.25,<3
Requires-Python: >=3.10, <4
Project-URL: Homepage, https://modern-di.modern-python.org
Project-URL: Documentation, https://modern-di.modern-python.org
Project-URL: Repository, https://github.com/modern-python/modern-di-aiogram
Project-URL: Issues, https://github.com/modern-python/modern-di-aiogram/issues
Project-URL: Changelog, https://github.com/modern-python/modern-di-aiogram/releases
Description-Content-Type: text/markdown

# modern-di-aiogram

[Modern-DI](https://github.com/modern-python/modern-di) integration for [aiogram](https://docs.aiogram.dev) 3.x.

## Quickstart

```python
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](https://modern-di.modern-python.org) for the full guide, including `auto_inject`.
