Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modern_di_aiogram-2.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modern_di_aiogram-2.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file modern_di_aiogram-2.1.0.tar.gz.

File metadata

  • Download URL: modern_di_aiogram-2.1.0.tar.gz
  • Upload date:
  • Size: 4.4 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

Hashes for modern_di_aiogram-2.1.0.tar.gz
Algorithm Hash digest
SHA256 5e2486ee2d97f1845a6e2fd241ce66792897e3ffa73049bc5c1758fd9f46bfa3
MD5 068808a6fa7370e9deef9f52f822fb46
BLAKE2b-256 6c489ce5cd3bcffba0a854406896f5f139ea798d84fed3b87d84e73375512250

See more details on using hashes here.

File details

Details for the file modern_di_aiogram-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: modern_di_aiogram-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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

Hashes for modern_di_aiogram-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 521932985712190ae6a7cef93ff2f0e43eca57bdce331278230cc87a6b63d689
MD5 6e8bf68deefbfccb5a60b3a2a773d7a9
BLAKE2b-256 b489e3acfd58968bd11852a93d072fabec9e0ef7b4575bcfd37b25892b7adba9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page