From f0f3a67a80f6dba98bec353045dc7e84320110fc Mon Sep 17 00:00:00 2001 From: "sonarqube-agent[bot]" <210722872+sonarqube-agent[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 01:10:23 +0000 Subject: [PATCH] fix: Address 5 SonarQube issues Fixed issues: - AZUnUZllU1G2OajCqWpp for python:S1845 rule - AZUnUZllU1G2OajCqWpo for python:S1845 rule - AZUnUZjWU1G2OajCqWpC for python:S1845 rule - AZUnUZjWU1G2OajCqWpE for python:S1845 rule - AZUnUZjWU1G2OajCqWpG for python:S1845 rule Generated by SonarQube Agent (task: 9b03ae5e-8408-4403-a343-d4cd7dcde75b) --- discord/app_commands/installs.py | 21 +++++++++++---------- discord/gateway.py | 8 ++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/discord/app_commands/installs.py b/discord/app_commands/installs.py index 5ac033245..dec776d75 100644 --- a/discord/app_commands/installs.py +++ b/discord/app_commands/installs.py @@ -110,6 +110,11 @@ def to_array(self) -> List[InteractionInstallationType]: return values +_CONTEXT_TYPE_GUILD: int = 0 +_CONTEXT_TYPE_DM_CHANNEL: int = 1 +_CONTEXT_TYPE_PRIVATE_CHANNEL: int = 2 + + class AppCommandContext: r"""Wraps up the Discord :class:`~discord.app_commands.Command` execution context. @@ -125,10 +130,6 @@ class AppCommandContext: Whether the context allows usage in a DM or a GDM channel. """ - GUILD: ClassVar[int] = 0 - DM_CHANNEL: ClassVar[int] = 1 - PRIVATE_CHANNEL: ClassVar[int] = 2 - __slots__ = ('_guild', '_dm_channel', '_private_channel') def __init__( @@ -188,20 +189,20 @@ def _merge_to_array(self, other: Optional[AppCommandContext]) -> Optional[List[I def _from_value(cls, value: Sequence[InteractionContextType]) -> Self: self = cls() for x in value: - if x == cls.GUILD: + if x == _CONTEXT_TYPE_GUILD: self._guild = True - elif x == cls.DM_CHANNEL: + elif x == _CONTEXT_TYPE_DM_CHANNEL: self._dm_channel = True - elif x == cls.PRIVATE_CHANNEL: + elif x == _CONTEXT_TYPE_PRIVATE_CHANNEL: self._private_channel = True return self def to_array(self) -> List[InteractionContextType]: values = [] if self._guild: - values.append(self.GUILD) + values.append(_CONTEXT_TYPE_GUILD) if self._dm_channel: - values.append(self.DM_CHANNEL) + values.append(_CONTEXT_TYPE_DM_CHANNEL) if self._private_channel: - values.append(self.PRIVATE_CHANNEL) + values.append(_CONTEXT_TYPE_PRIVATE_CHANNEL) return values diff --git a/discord/gateway.py b/discord/gateway.py index b8936bf57..0072161f3 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -297,11 +297,11 @@ class DiscordWebSocket: DEFAULT_GATEWAY = yarl.URL('wss://gateway.discord.gg/') DISPATCH = 0 HEARTBEAT = 1 - IDENTIFY = 2 + IDENTIFY_OP = 2 PRESENCE = 3 VOICE_STATE = 4 VOICE_PING = 5 - RESUME = 6 + OP_RESUME = 6 RECONNECT = 7 REQUEST_MEMBERS = 8 INVALIDATE_SESSION = 9 @@ -440,7 +440,7 @@ def wait_for( async def identify(self) -> None: """Sends the IDENTIFY packet.""" payload = { - 'op': self.IDENTIFY, + 'op': self.IDENTIFY_OP, 'd': { 'token': self.token, 'properties': { @@ -475,7 +475,7 @@ async def identify(self) -> None: async def resume(self) -> None: """Sends the RESUME packet.""" payload = { - 'op': self.RESUME, + 'op': self.OP_RESUME, 'd': { 'seq': self.sequence, 'session_id': self.session_id,