From 5da75556cd09e20e75a760b51dbc86e9ac013e0b Mon Sep 17 00:00:00 2001 From: davfsa Date: Sun, 29 Oct 2023 19:56:27 +0100 Subject: [PATCH] Fix typing issues and usage of typing.EXCLUDED_ATTRIBUTES --- hikari/impl/shard.py | 3 ++- hikari/internal/fast_protocol.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hikari/impl/shard.py b/hikari/impl/shard.py index 5738941cf2..475fd8bb88 100644 --- a/hikari/impl/shard.py +++ b/hikari/impl/shard.py @@ -219,7 +219,8 @@ def _handle_other_message(self, message: aiohttp.WSMessage, /) -> typing.NoRetur close_code = int(message.data) can_reconnect = close_code < 4000 or close_code in _RECONNECTABLE_CLOSE_CODES - raise errors.GatewayServerClosedConnectionError(message.extra, close_code, can_reconnect) + # str(message.extra) is used to cast the possible None to a string + raise errors.GatewayServerClosedConnectionError(str(message.extra), close_code, can_reconnect) if message.type == aiohttp.WSMsgType.CLOSING or message.type == aiohttp.WSMsgType.CLOSED: # May be caused by the server shutting us down. diff --git a/hikari/internal/fast_protocol.py b/hikari/internal/fast_protocol.py index a313578039..e8995c39d8 100644 --- a/hikari/internal/fast_protocol.py +++ b/hikari/internal/fast_protocol.py @@ -32,7 +32,7 @@ from typing_extensions import Self _Protocol: FastProtocolChecking = NotImplemented -_IGNORED_ATTRS = typing.EXCLUDED_ATTRIBUTES + ["__qualname__", "__slots__"] +_IGNORED_ATTRS = frozenset(tuple(typing.EXCLUDED_ATTRIBUTES) + ("__qualname__", "__slots__")) def _check_if_ignored(name: str) -> bool: