Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/team-roles
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv committed Oct 26, 2023
2 parents 98813fa + 3591556 commit db4496c
Show file tree
Hide file tree
Showing 70 changed files with 313 additions and 172 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
experimental: [false]
fail-fast: false
continue-on-error: ${{ matrix.experimental }}
Expand All @@ -72,7 +72,9 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pdm install -d -Gspeed -Gdocs -Gvoice
run: |
pdm update --pre aiohttp # XXX: temporarily install aiohttp prerelease for 3.12
pdm install -d -Gspeed -Gdocs -Gvoice
- name: Add .venv/bin to PATH
run: dirname "$(pdm info --python)" >> $GITHUB_PATH
Expand Down Expand Up @@ -129,12 +131,13 @@ jobs:
# run the libcst parsers and check for changes
- name: libcst codemod
env:
LIBCST_PARSER_TYPE: "native"
run: |
nox -s codemod -- run-all
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Please run 'nox -s codemod -- run-all' locally and commit the changes." >&2;
echo "::group::git diff"
git diff
echo "::endgroup::"
exit 1;
else
exit 0;
Expand All @@ -144,7 +147,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
experimental: [false]
fail-fast: true
Expand All @@ -164,11 +167,13 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pdm install -dG test # needed for coverage
run: |
pdm update --pre aiohttp # XXX: temporarily install aiohttp prerelease for 3.12
pdm install -dG test # needed for coverage
- name: Test package install
run: |
python -m pip install .
python -m pip install --pre . # XXX: temporarily install aiohttp prerelease for 3.12; remove --pre flag again later
- name: Run pytest
id: run_tests
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ repos:
name: "run isort in examples"
files: ^examples/

- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black
name: "run black in all files"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.261
rev: v0.0.292
hooks:
- id: ruff
1 change: 1 addition & 0 deletions changelog/1079.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :attr:`RawReactionActionEvent.message_author_id`.
1 change: 1 addition & 0 deletions changelog/1102.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update :meth:`Colour.dark_theme` to match Discord theme change.
1 change: 1 addition & 0 deletions changelog/1102.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add new :class:`Colour`\s: :meth:`~Colour.light_embed` and :meth:`~Colour.dark_embed`.
1 change: 1 addition & 0 deletions changelog/1117.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Start testing with Python 3.12 in CI.
1 change: 1 addition & 0 deletions changelog/1120.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|commands| Fix edge case in evaluation of multiple identical annotations with forwardrefs in a single signature.
1 change: 1 addition & 0 deletions changelog/1123.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :meth:`Thread.permissions_for` not working in some cases due to an incorrect import.
1 change: 1 addition & 0 deletions changelog/1126.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make all "Supported Operations" container elements collapsible.
1 change: 1 addition & 0 deletions changelog/882.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``guild_scheduled_event`` parameter to :meth:`StageChannel.create_instance`.
8 changes: 4 additions & 4 deletions disnake/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class Game(BaseActivity):
This is typically displayed via **Playing** on the official Discord client.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -487,7 +487,7 @@ class Streaming(BaseActivity):
This is typically displayed via **Streaming** on the official Discord client.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -597,7 +597,7 @@ def __hash__(self) -> int:
class Spotify(_BaseActivity):
"""Represents a Spotify listening activity from Discord.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -770,7 +770,7 @@ def party_id(self) -> str:
class CustomActivity(BaseActivity):
"""Represents a Custom activity from Discord.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down
2 changes: 1 addition & 1 deletion disnake/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def to_file(
class Asset(AssetMixin):
"""Represents a CDN asset on Discord.
.. container:: operations
.. collapse:: operations
.. describe:: str(x)
Expand Down
2 changes: 1 addition & 1 deletion disnake/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ class AuditLogEntry(Hashable):
You can retrieve these via :meth:`Guild.audit_logs`,
or via the :func:`on_audit_log_entry_create` event.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down
31 changes: 21 additions & 10 deletions disnake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def _single_delete_strategy(messages: Iterable[Message]) -> None:
class TextChannel(disnake.abc.Messageable, disnake.abc.GuildChannel, Hashable):
"""Represents a Discord guild text channel.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -1217,7 +1217,7 @@ def permissions_for(
class VoiceChannel(disnake.abc.Messageable, VocalGuildChannel):
"""Represents a Discord guild voice channel.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -1871,7 +1871,7 @@ class StageChannel(disnake.abc.Messageable, VocalGuildChannel):
.. versionadded:: 1.7
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -2193,6 +2193,7 @@ async def create_instance(
topic: str,
privacy_level: StagePrivacyLevel = MISSING,
notify_everyone: bool = False,
guild_scheduled_event: Snowflake = MISSING,
reason: Optional[str] = None,
) -> StageInstance:
"""|coro|
Expand All @@ -2213,15 +2214,22 @@ async def create_instance(
The stage instance's topic.
privacy_level: :class:`StagePrivacyLevel`
The stage instance's privacy level. Defaults to :attr:`StagePrivacyLevel.guild_only`.
reason: Optional[:class:`str`]
The reason the stage instance was created. Shows up on the audit log.
notify_everyone: :class:`bool`
Whether to notify ``@everyone`` that the stage instance has started.
Requires the :attr:`~Permissions.mention_everyone` permission on the stage channel.
Defaults to ``False``.
.. versionadded:: 2.5
guild_scheduled_event: :class:`abc.Snowflake`
The guild scheduled event associated with the stage instance.
Setting this will automatically start the event.
.. versionadded:: 2.10
reason: Optional[:class:`str`]
The reason the stage instance was created. Shows up on the audit log.
Raises
------
Forbidden
Expand Down Expand Up @@ -2253,6 +2261,9 @@ async def create_instance(

payload["privacy_level"] = privacy_level.value

if guild_scheduled_event is not MISSING:
payload["guild_scheduled_event_id"] = guild_scheduled_event.id

data = await self._state.http.create_stage_instance(**payload, reason=reason)
return StageInstance(guild=self.guild, state=self._state, data=data)

Expand Down Expand Up @@ -2685,7 +2696,7 @@ class CategoryChannel(disnake.abc.GuildChannel, Hashable):
These are useful to group channels to logical compartments.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -3134,7 +3145,7 @@ class ForumChannel(disnake.abc.GuildChannel, Hashable):
.. versionadded:: 2.5
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -4173,7 +4184,7 @@ def get_tag_by_name(self, name: str, /) -> Optional[ForumTag]:
class DMChannel(disnake.abc.Messageable, Hashable):
"""Represents a Discord direct message channel.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -4336,7 +4347,7 @@ def get_partial_message(self, message_id: int, /) -> PartialMessage:
class GroupChannel(disnake.abc.Messageable, Hashable):
"""Represents a Discord group channel.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -4495,7 +4506,7 @@ class PartialMessageable(disnake.abc.Messageable, Hashable):
.. versionadded:: 2.0
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down
24 changes: 21 additions & 3 deletions disnake/colour.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Colour:
There is an alias for this called Color.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down Expand Up @@ -278,12 +278,12 @@ def greyple(cls) -> Self:

@classmethod
def dark_theme(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x36393F``.
"""A factory method that returns a :class:`Colour` with a value of ``0x313338``.
This will appear transparent on Discord's dark theme.
.. versionadded:: 1.5
"""
return cls(0x36393F)
return cls(0x313338)

@classmethod
def fuchsia(cls) -> Self:
Expand All @@ -301,5 +301,23 @@ def yellow(cls) -> Self:
"""
return cls(0xFEE75C)

@classmethod
def light_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0xF2F3F5``.
This matches the embed background colour on Discord's light theme.
.. versionadded:: 2.10
"""
return cls(0xF2F3F5)

@classmethod
def dark_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x2B2D31``.
This matches the embed background colour on Discord's dark theme.
.. versionadded:: 2.10
"""
return cls(0x2B2D31)


Color = Colour
2 changes: 1 addition & 1 deletion disnake/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class _EmbedAuthorProxy(Sized, Protocol):
class Embed:
"""Represents a Discord embed.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down
2 changes: 1 addition & 1 deletion disnake/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Emoji(_EmojiTag, AssetMixin):
Depending on the way this object was created, some of the attributes can
have a value of ``None``.
.. container:: operations
.. collapse:: operations
.. describe:: x == y
Expand Down
6 changes: 3 additions & 3 deletions disnake/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,15 +763,15 @@ def __str__(self) -> str:
# reference: https://discord.com/developers/docs/reference#locales
class Locale(Enum):
bg = "bg"
"Bulgarian | български" # noqa: RUF001
"Bulgarian | български"
cs = "cs"
"Czech | Čeština"
da = "da"
"Danish | Dansk"
de = "de"
"German | Deutsch"
el = "el"
"Greek | Ελληνικά" # noqa: RUF001
"Greek | Ελληνικά"
en_GB = "en-GB"
"English, UK | English, UK"
en_US = "en-US"
Expand Down Expand Up @@ -817,7 +817,7 @@ class Locale(Enum):
tr = "tr"
"Turkish | Türkçe"
uk = "uk"
"Ukrainian | Українська" # noqa: RUF001
"Ukrainian | Українська"
vi = "vi"
"Vietnamese | Tiếng Việt"
zh_CN = "zh-CN"
Expand Down
6 changes: 3 additions & 3 deletions disnake/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Mapping, Optional, Tuple, Union

if TYPE_CHECKING:
from aiohttp import ClientResponse, ClientWebSocketResponse
Expand Down Expand Up @@ -225,7 +225,7 @@ class ConnectionClosed(ClientException):
"""

# https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes
GATEWAY_CLOSE_EVENT_REASONS: Dict[int, str] = {
GATEWAY_CLOSE_EVENT_REASONS: ClassVar[Mapping[int, str]] = {
4000: "Unknown error",
4001: "Unknown opcode",
4002: "Decode error",
Expand All @@ -243,7 +243,7 @@ class ConnectionClosed(ClientException):
}

# https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
GATEWAY_VOICE_CLOSE_EVENT_REASONS: Dict[int, str] = {
GATEWAY_VOICE_CLOSE_EVENT_REASONS: ClassVar[Mapping[int, str]] = {
**GATEWAY_CLOSE_EVENT_REASONS,
4002: "Failed to decode payload",
4006: "Session no longer valid",
Expand Down
3 changes: 1 addition & 2 deletions disnake/ext/commands/common_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import asyncio
import collections.abc
import importlib.machinery
import importlib.util
import logging
import os
Expand All @@ -19,8 +20,6 @@
from .cog import Cog

if TYPE_CHECKING:
import importlib.machinery

from ._types import CoroFunc
from .bot import AutoShardedBot, AutoShardedInteractionBot, Bot, InteractionBot
from .help import HelpCommand
Expand Down
Loading

0 comments on commit db4496c

Please sign in to comment.