Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maksimzayats/aiogram-di
https://github.com/maksimzayats/aiogram-di
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/maksimzayats/aiogram-di
- Owner: MaksimZayats
- Created: 2022-09-01T14:25:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-21T17:53:25.000Z (about 2 years ago)
- Last Synced: 2024-10-13T14:13:45.646Z (3 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```python
from aiogram_di import DIMiddleware@dataclass
class A:
id: intdp.message.middleware(
DIMiddleware(
{
A: lambda: A(id=1),
}
)
)
```* ### Usage
```python
@dp.message()
async def handler(
message: Message,
a: A, # <- will be injected
) -> None:
assert a.id == 1
```