Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/lib-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ jobs:
with:
python-version: "3.14"
groups: "dev"
extras: "voice,speed"
- name: "Setup cache"
id: cache-pylint
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
Expand All @@ -140,7 +141,11 @@ jobs:
restore-keys: |
pylint-${{ runner.os }}-py3.14-
- name: "Run pylint"
run: pylint discord/ --exit-zero
run: |
pylint discord/ \
--output-format=github,json:pylint.json \
--fail-under=0 \
--fail-on=E,F
mypy:
needs: [ changes ]
if: ${{ needs.changes.outputs.lib == 'true' && github.event_name != 'schedule' }}
Expand Down
6 changes: 4 additions & 2 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@
@deprecated(
"discord.VoiceClient is deprecated in favour of discord.voice.VoiceClient since 2.7 and will be removed in 3.0",
)
class VoiceClient(VoiceClientC): ...
class VoiceClient(VoiceClientC): ... # pylint: disable=function-redefined

Check notice on line 95 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

C0115

Missing class docstring

@deprecated(
"discord.VoiceProtocol is deprecated in favour of discord.voice.VoiceProtocol since 2.7 and will be removed in 3.0",

Check notice on line 98 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

C0301

Line too long (124/120)
)
class VoiceProtocol(VoiceProtocolC[C], Generic[C]): ...
class VoiceProtocol( # pylint: disable=function-redefined

Check warning on line 100 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

W0223

Method 'on_voice_state_update' is abstract in class 'VoiceProtocol' but is not overridden in child class 'VoiceProtocol'

Check warning on line 100 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

W0223

Method 'on_voice_server_update' is abstract in class 'VoiceProtocol' but is not overridden in child class 'VoiceProtocol'

Check warning on line 100 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

W0223

Method 'connect' is abstract in class 'VoiceProtocol' but is not overridden in child class 'VoiceProtocol'

Check notice on line 100 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

C0115

Missing class docstring
VoiceProtocolC[C], Generic[C]
): ...

else:
from .utils import warn_deprecated
Expand All @@ -107,14 +109,14 @@
warn_deprecated(
"discord.VoiceClient", "discord.voice.VoiceClient", "2.7", "3.0"
)
from .voice import VoiceClient

Check notice on line 112 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

C0415

Import outside toplevel (voice.VoiceClient)

return VoiceClient
if name == "VoiceProtocol":
warn_deprecated(
"discord.VoiceProtocol", "discord.voice.VoiceProtocol", "2.7", "3.0"
)
from .voice import VoiceProtocol

Check notice on line 119 in discord/__init__.py

View workflow job for this annotation

GitHub Actions / pylint

C0415

Import outside toplevel (voice.VoiceProtocol)

return VoiceProtocol
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
Expand Down
2 changes: 1 addition & 1 deletion discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _cleanup_loop(loop: asyncio.AbstractEventLoop) -> None:
loop.close()


class Client:
class Client: # pylint: disable=function-redefined
r"""Represents a client connection that connects to Discord.
This class is used to interact with the Discord WebSocket and API.

Expand Down
2 changes: 1 addition & 1 deletion discord/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
ApplicationCommand,
ApplicationContext,
SlashCommandGroup,
_BaseCommand,
)
from .commands.core import _BaseCommand

if TYPE_CHECKING:
from .ext.bridge import BridgeCommand
Expand Down
4 changes: 2 additions & 2 deletions discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class Component:

__slots__: tuple[str, ...] = ("type", "id")

__repr_info__: ClassVar[tuple[str, ...]]
__repr_info__: ClassVar[tuple[str, ...]] # pylint: disable=declare-non-slot
type: ComponentType
versions: tuple[int, ...]
versions: tuple[int, ...] # pylint: disable=declare-non-slot

def __repr__(self) -> str:
attrs = " ".join(f"{key}={getattr(self, key)!r}" for key in self.__repr_info__)
Expand Down
4 changes: 2 additions & 2 deletions discord/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def decorator(cls: type[BF]):

# n.b. flags must inherit from this and use the decorator above
class BaseFlags:
VALID_FLAGS: ClassVar[dict[str, int]]
DEFAULT_VALUE: ClassVar[int]
VALID_FLAGS: ClassVar[dict[str, int]] # pylint: disable=declare-non-slot
DEFAULT_VALUE: ClassVar[int] # pylint: disable=declare-non-slot

value: int

Expand Down
2 changes: 1 addition & 1 deletion discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def __contains__(self, key: int | abc.Snowflake) -> bool:
return super().__contains__(key)


class Guild(Hashable):
class Guild(Hashable): # pylint: disable=function-redefined
"""Represents a Discord guild.

This is referred to as a "server" in the official Discord UI.
Expand Down
2 changes: 1 addition & 1 deletion discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

import aiohttp

from . import __version__, utils
from . import __version__, utils # pylint: disable=no-name-in-module
from .errors import (
DiscordServerError,
Forbidden,
Expand Down
16 changes: 12 additions & 4 deletions discord/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ async def fill_messages(self):
self.state.create_message(channel=channel, data=element)
)

async def _retrieve_messages(self, retrieve: int) -> list[MessagePayload]:
async def _retrieve_messages( # pylint: disable=method-hidden
self, retrieve: int
) -> list[MessagePayload]:
"""Retrieve messages and update next parameters."""
raise NotImplementedError

Expand Down Expand Up @@ -657,7 +659,9 @@ async def fill_guilds(self):
for element in data:
await self.guilds.put(self.create_guild(element))

async def _retrieve_guilds(self, retrieve) -> list[Guild]:
async def _retrieve_guilds( # pylint: disable=method-hidden
self, retrieve
) -> list[Guild]:
"""Retrieve guilds and update next parameters."""
raise NotImplementedError

Expand Down Expand Up @@ -1055,7 +1059,9 @@ async def fill_entitlements(self):
for element in data:
await self.entitlements.put(self.create_entitlement(element))

async def _retrieve_entitlements(self, retrieve) -> list[EntitlementPayload]:
async def _retrieve_entitlements( # pylint: disable=method-hidden
self, retrieve
) -> list[EntitlementPayload]:
"""Retrieve entitlements and update next parameters."""
raise NotImplementedError

Expand Down Expand Up @@ -1170,7 +1176,9 @@ async def fill_subscriptions(self):
for element in data:
await self.subscriptions.put(self.create_subscription(element))

async def _retrieve_subscriptions(self, retrieve) -> list[SubscriptionPayload]:
async def _retrieve_subscriptions( # pylint: disable=method-hidden
self, retrieve
) -> list[SubscriptionPayload]:
raise NotImplementedError

async def _retrieve_subscriptions_before_strategy(self, retrieve):
Expand Down
2 changes: 0 additions & 2 deletions discord/raw_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@


class _RawReprMixin:
__slots__: tuple[str, ...]

def __repr__(self) -> str:
value = " ".join(
f"{attr}={getattr(self, attr)!r}"
Expand Down
6 changes: 3 additions & 3 deletions discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def logging_coroutine(coroutine: Coroutine[Any, Any, T], *, info: str) ->
_log.exception("Exception occurred during %s", info)


class ConnectionState:
class ConnectionState: # pylint: disable=function-redefined
if TYPE_CHECKING:
_get_websocket: Callable[..., DiscordWebSocket]
_get_client: Callable[..., Client]
Expand Down Expand Up @@ -369,7 +369,7 @@ def _update_references(self, ws: DiscordWebSocket) -> None:
for vc in self.voice_clients:
vc.main_ws = ws # type: ignore

def store_user(self, data: UserPayload) -> User:
def store_user(self, data: UserPayload) -> User: # pylint: disable=method-hidden
user_id = int(data["id"])
try:
user = self._users[user_id]
Expand All @@ -388,7 +388,7 @@ def store_user(self, data: UserPayload) -> User:
copied_user._update(data)
return copied_user

def deref_user(self, user_id: int) -> None:
def deref_user(self, user_id: int) -> None: # pylint: disable=method-hidden
self._users.pop(user_id, None)

def create_user(self, data: UserPayload) -> User:
Expand Down
2 changes: 1 addition & 1 deletion discord/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def __del__(self) -> None:
@classmethod
def _copy(cls, user: User):
self = super()._copy(user)
self._stored = False
self._stored = False # pylint: disable=assigning-non-slot
return self

async def _get_channel(self) -> DMChannel:
Expand Down
4 changes: 3 additions & 1 deletion discord/voice/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ def _get_voice_packet(self, data: Any) -> bytes:

def _encrypt_xsalsa20_poly1305(self, header: bytes, data: Any) -> bytes:
# deprecated
box = nacl.secret.SecretBox(bytes(self.secret_key))
box = nacl.secret.SecretBox( # pylint: disable=possibly-used-before-assignment
bytes(self.secret_key)
)
nonce = bytearray(24)
nonce[:12] = header
return header + box.encrypt(bytes(data), bytes(nonce)).ciphertext
Expand Down
4 changes: 2 additions & 2 deletions discord/voice/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def session_id(self, value: str | None) -> None:
def self_id(self) -> int:
return self._connection.self_id

async def _hook(self, *args: Any) -> Any:
async def _hook(self, *args: Any) -> Any: # pylint: disable=method-hidden
pass

async def send_as_bytes(self, op: ConvertibleToInt, data: bytes) -> None:
Expand Down Expand Up @@ -276,7 +276,7 @@ async def received_binary_message(self, msg: bytes) -> None:
op_type = msg[3]
result = state.dave_session.process_proposals(
(
davey.ProposalsOperationType.append
davey.ProposalsOperationType.append # pylint: disable=possibly-used-before-assignment
if op_type == 0
else davey.ProposalsOperationType.revoke
),
Expand Down
5 changes: 3 additions & 2 deletions discord/voice/receive/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
DecryptRTP = Callable[[RTPPacket], bytes]
DecryptRTCP = Callable[[bytes], bytes]
SpeakingEvent = Literal["member_speaking_start", "member_speaking_stop"]
# pylint: disable-next=possibly-used-before-assignment
EncryptionBox = nacl.secret.SecretBox | nacl.secret.Aead

_log = logging.getLogger(__name__)
Expand Down Expand Up @@ -187,7 +188,7 @@ def callback(self, packet_data: bytes) -> None:
packet.type,
type(packet),
)
except CryptoError as exc:
except CryptoError as exc: # pylint: disable=possibly-used-before-assignment
_log.error("CryptoError while decoding a voice packet", exc_info=exc)
return
except Exception as exc:
Expand Down Expand Up @@ -303,7 +304,7 @@ def decrypt_rtp(self, packet: RTPPacket) -> bytes:
try:
decrypted_audio = dave.decrypt(
uid,
davey.MediaType.audio,
davey.MediaType.audio, # pylint: disable=possibly-used-before-assignment
raw_payload,
)

Expand Down
4 changes: 2 additions & 2 deletions discord/webhook/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def partial(
"type": 1,
"token": token,
}
import requests
import requests # pylint: disable=import-error

if session is MISSING:
session = requests # type: ignore
Expand Down Expand Up @@ -736,7 +736,7 @@ def from_url(

data: dict[str, Any] = m.groupdict()
data["type"] = 1
import requests
import requests # pylint: disable=import-error

if session is MISSING:
session = requests # type: ignore
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ enable = [
]
disable = [
"protected-access",
"fixme"
"fixme",
"typecheck",
]

[tool.pylint.format]
Expand Down
Loading