extract raise_expected_coro further

This commit is contained in:
chillymosh
2021-08-28 22:52:58 +01:00
parent 1829048c80
commit 73a4996aa9
3 changed files with 30 additions and 36 deletions

View File

@@ -22,6 +22,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
from TwitchIO.twitchio.ext.commands import utils
from __future__ import annotations
@@ -43,6 +44,7 @@ from .context import Context
from . import errors
from .help import HelpCommand, DefaultHelpCommand
from .cog import Cog
from discord.utils import raise_expected_coro
if TYPE_CHECKING:
import importlib.machinery
@@ -379,7 +381,7 @@ class BotBase(GroupMixin):
TypeError
The coroutine passed is not actually a coroutine.
"""
return self._raise_expected_coro(
return raise_expected_coro(
coro, 'The pre-invoke hook must be a coroutine.'
)
@@ -410,17 +412,11 @@ class BotBase(GroupMixin):
TypeError
The coroutine passed is not actually a coroutine.
"""
return self._raise_expected_coro(
return raise_expected_coro(
coro, 'The post-invoke hook must be a coroutine.'
)
def _raise_expected_coro(self, coro, arg1):
if not asyncio.iscoroutinefunction(coro):
raise TypeError(arg1)
return coro
# listener registration
def add_listener(self, func: CoroFunc, name: str = MISSING) -> None: