Skip to content

Commit f0f3a67

Browse files
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)
1 parent 1593bed commit f0f3a67

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

discord/app_commands/installs.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ def to_array(self) -> List[InteractionInstallationType]:
110110
return values
111111

112112

113+
_CONTEXT_TYPE_GUILD: int = 0
114+
_CONTEXT_TYPE_DM_CHANNEL: int = 1
115+
_CONTEXT_TYPE_PRIVATE_CHANNEL: int = 2
116+
117+
113118
class AppCommandContext:
114119
r"""Wraps up the Discord :class:`~discord.app_commands.Command` execution context.
115120
@@ -125,10 +130,6 @@ class AppCommandContext:
125130
Whether the context allows usage in a DM or a GDM channel.
126131
"""
127132

128-
GUILD: ClassVar[int] = 0
129-
DM_CHANNEL: ClassVar[int] = 1
130-
PRIVATE_CHANNEL: ClassVar[int] = 2
131-
132133
__slots__ = ('_guild', '_dm_channel', '_private_channel')
133134

134135
def __init__(
@@ -188,20 +189,20 @@ def _merge_to_array(self, other: Optional[AppCommandContext]) -> Optional[List[I
188189
def _from_value(cls, value: Sequence[InteractionContextType]) -> Self:
189190
self = cls()
190191
for x in value:
191-
if x == cls.GUILD:
192+
if x == _CONTEXT_TYPE_GUILD:
192193
self._guild = True
193-
elif x == cls.DM_CHANNEL:
194+
elif x == _CONTEXT_TYPE_DM_CHANNEL:
194195
self._dm_channel = True
195-
elif x == cls.PRIVATE_CHANNEL:
196+
elif x == _CONTEXT_TYPE_PRIVATE_CHANNEL:
196197
self._private_channel = True
197198
return self
198199

199200
def to_array(self) -> List[InteractionContextType]:
200201
values = []
201202
if self._guild:
202-
values.append(self.GUILD)
203+
values.append(_CONTEXT_TYPE_GUILD)
203204
if self._dm_channel:
204-
values.append(self.DM_CHANNEL)
205+
values.append(_CONTEXT_TYPE_DM_CHANNEL)
205206
if self._private_channel:
206-
values.append(self.PRIVATE_CHANNEL)
207+
values.append(_CONTEXT_TYPE_PRIVATE_CHANNEL)
207208
return values

discord/gateway.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,11 @@ class DiscordWebSocket:
297297
DEFAULT_GATEWAY = yarl.URL('wss://gateway.discord.gg/')
298298
DISPATCH = 0
299299
HEARTBEAT = 1
300-
IDENTIFY = 2
300+
IDENTIFY_OP = 2
301301
PRESENCE = 3
302302
VOICE_STATE = 4
303303
VOICE_PING = 5
304-
RESUME = 6
304+
OP_RESUME = 6
305305
RECONNECT = 7
306306
REQUEST_MEMBERS = 8
307307
INVALIDATE_SESSION = 9
@@ -440,7 +440,7 @@ def wait_for(
440440
async def identify(self) -> None:
441441
"""Sends the IDENTIFY packet."""
442442
payload = {
443-
'op': self.IDENTIFY,
443+
'op': self.IDENTIFY_OP,
444444
'd': {
445445
'token': self.token,
446446
'properties': {
@@ -475,7 +475,7 @@ async def identify(self) -> None:
475475
async def resume(self) -> None:
476476
"""Sends the RESUME packet."""
477477
payload = {
478-
'op': self.RESUME,
478+
'op': self.OP_RESUME,
479479
'd': {
480480
'seq': self.sequence,
481481
'session_id': self.session_id,

0 commit comments

Comments
 (0)