Utility for chaining awaits
|
All checks were successful
Test with Pytest the Python package using Poetry / Run tests (push) Successful in 8s
Release using Poetry a new version of the Python package / Build package (push) Successful in 7s
Release using Poetry a new version of the Python package / Publish package on Forgejo Packages (push) Successful in 2s
Release using Poetry a new version of the Python package / Publish package on Test PyPI (push) Successful in 5s
Release using Poetry a new version of the Python package / Publish package on PyPI (push) Successful in 4s
|
||
|---|---|---|
| .forgejo/workflows | ||
| .idea | ||
| .media | ||
| async_chain | ||
| tests | ||
| .editorconfig | ||
| .gitignore | ||
| async-chain.iml | ||
| LICENSE.txt | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
Async Chain
Utility for chaining awaits
About
This package allows library developers to write interfaces that are both fluent and async, avoiding ugly syntax, like in the following example:
async def on_message(event):
# bad!
(await (await (await event.get_message()).get_author()).send_message("Hello world!"))
Instead, by marking all involved methods with the @async_chain.method decorator:
import async_chain
class MyEvent:
@async_chain.method
async def get_message(self):
...
The following syntax can be achieved:
async def on_message(event):
# nice!
await event.get_message().get_author().send_message("Hello world!")