From 8f2b367e0b7cd43bddc052e654aca6d6861fe643 Mon Sep 17 00:00:00 2001 From: TheLeadingLlama <44980366+StockerMC@users.noreply.github.com> Date: Thu, 19 Aug 2021 18:43:52 -0400 Subject: [PATCH] Change EventListener to subclass NamedTuple --- discord/gateway.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/discord/gateway.py b/discord/gateway.py index 12bdb87d..f77037b9 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -24,10 +24,10 @@ DEALINGS IN THE SOFTWARE. from __future__ import annotations -from typing import TYPE_CHECKING, TypedDict, Any, Optional, List, TypeVar, Type, Dict, Callable, Coroutine +from typing import TYPE_CHECKING, TypedDict, Any, Optional, List, TypeVar, Type, Dict, Callable, Coroutine, NamedTuple import asyncio -from collections import namedtuple, deque +from collections import deque import concurrent.futures import logging import struct @@ -81,7 +81,11 @@ class WebSocketClosure(Exception): pass -EventListener = namedtuple('EventListener', 'predicate event result future') +class EventListener(NamedTuple): + predicate: Callable[[Dict[str, Any]], bool] + event: str + result: Optional[Callable[[Dict[str, Any]], Any]] + future: asyncio.Future class GatewayRatelimiter: