From 68c929cddfc420fa4b95c08059a2bb41717aa10e Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 16 Jan 2023 22:03:31 -0500 Subject: [PATCH] Use Mapping instead of Dict for AuditLogEntry inner cache data --- discord/audit_logs.py | 20 ++++++++++---------- discord/state.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/discord/audit_logs.py b/discord/audit_logs.py index 29b472144..95e846d68 100644 --- a/discord/audit_logs.py +++ b/discord/audit_logs.py @@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, ClassVar, Dict, Generator, List, Optional, Tuple, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, Callable, ClassVar, Mapping, Generator, List, Optional, Tuple, Type, TypeVar, Union from . import enums, flags, utils from .asset import Asset @@ -315,7 +315,7 @@ Transformer = Callable[["AuditLogEntry", Any], Any] class AuditLogChanges: # fmt: off - TRANSFORMERS: ClassVar[Dict[str, Tuple[Optional[str], Optional[Transformer]]]] = { + TRANSFORMERS: ClassVar[Mapping[str, Tuple[Optional[str], Optional[Transformer]]]] = { 'verification_level': (None, _enum_transformer(enums.VerificationLevel)), 'explicit_content_filter': (None, _enum_transformer(enums.ContentFilter)), 'allow': (None, _flag_transformer(Permissions)), @@ -568,19 +568,19 @@ class AuditLogEntry(Hashable): def __init__( self, *, - users: Dict[int, User], - integrations: Dict[int, PartialIntegration], - app_commands: Dict[int, AppCommand], - automod_rules: Dict[int, AutoModRule], + users: Mapping[int, User], + integrations: Mapping[int, PartialIntegration], + app_commands: Mapping[int, AppCommand], + automod_rules: Mapping[int, AutoModRule], data: AuditLogEntryPayload, guild: Guild, ): self._state: ConnectionState = guild._state self.guild: Guild = guild - self._users: Dict[int, User] = users - self._integrations: Dict[int, PartialIntegration] = integrations - self._app_commands: Dict[int, AppCommand] = app_commands - self._automod_rules: Dict[int, AutoModRule] = automod_rules + self._users: Mapping[int, User] = users + self._integrations: Mapping[int, PartialIntegration] = integrations + self._app_commands: Mapping[int, AppCommand] = app_commands + self._automod_rules: Mapping[int, AutoModRule] = automod_rules self._from_data(data) def _from_data(self, data: AuditLogEntryPayload) -> None: diff --git a/discord/state.py b/discord/state.py index c47a9ab80..84b3b8f89 100644 --- a/discord/state.py +++ b/discord/state.py @@ -1105,7 +1105,7 @@ class ConnectionState(Generic[ClientT]): return entry = AuditLogEntry( - users=self._users, # type: ignore + users=self._users, integrations={}, app_commands={}, automod_rules={},