pinterest / slackminion

A python bot framework for slack
MIT License
22 stars 14 forks source link

Use await/async thanks to slack_sdk #61

Closed jogo closed 2 years ago

jogo commented 2 years ago

The slack_sdk async web client now returns coroutines instead of futures so we now need more async/await keywords to ensure things still work.

The new slack_sdk web client calls are async while the old one returns a Future (when run_async=True) via ensure_future. And ensure_future makes sure the co-routine is always scheduled https://docs.python.org/3/library/asyncio-future.html

https://github.com/slackapi/python-slack-sdk/blob/main/slack_sdk/web/async_client.py https://github.com/slackapi/python-slack-sdk/blob/555c891a4270df407f01e97a8ed322f58828815d/slack_sdk/web/legacy_client.py#L31 https://github.com/slackapi/python-slack-sdk/blob/v2/slack/web/client.py

In order to catch these cases use typing and pyright.

This now requires python 3.7 due to https://www.python.org/dev/peps/pep-0563/ https://docs.python.org/3/library/typing.html#constant