Skip to main content

No project description provided

Project description

Aiogram DI

Installation

  • Latest version from GitHub

    pip install git+https://github.com/MaximZayats/aiogram-di
    
  • From PyPi

    pip install -U aiogram-di
    

Usage

  • Initialization

    from aiogram_di import DIMiddleware
    
    @dataclass
    class A:
        id: int
    
    dp.message.middleware(
        DIMiddleware(
            {
                A: lambda: A(id=1),
            }
        )
    )
    
  • Usage

    @dp.message()
    async def handler(
        message: Message,
        a: A,  # <- will be injected
    ) -> None:
      assert a.id == 1
    

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

aiogram-di-0.1.0.tar.gz (1.9 kB view hashes)

Uploaded Source

Built Distribution

aiogram_di-0.1.0-py3-none-any.whl (1.4 kB view hashes)

Uploaded Python 3

Supported by

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