Skip to content

Commit

Permalink
Merge branch 'master' into onboarding
Browse files Browse the repository at this point in the history
Signed-off-by: Lala Sabathil <lala@pycord.dev>
  • Loading branch information
Lulalaby authored Jul 24, 2023
2 parents 11f096c + 7fdc946 commit 97d8f3e
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 50 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
rev: v2.2.0
hooks:
- id: autoflake
# args:
Expand All @@ -19,7 +19,7 @@ repos:
# - --remove-duplicate-keys
# - --remove-unused-variables
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
rev: v3.9.0
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand All @@ -28,7 +28,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
args: [--safe, --quiet]
Expand Down Expand Up @@ -77,7 +77,7 @@ repos:
# - id: mypy

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
rev: v3.0.0
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ These changes are available on the `master` branch, but have not yet been releas
[Raw Event payloads](https://docs.pycord.dev/en/master/api/models.html#events).
([#2023](https://github.com/Pycord-Development/pycord/pull/2023))
- Added and documented missing `AuditLogAction` enums.
([#2030](https://github.com/Pycord-Development/pycord/pull/2030))
([#2030](https://github.com/Pycord-Development/pycord/pull/2030),
[#2171](https://github.com/Pycord-Development/pycord/pull/2171))
- `AuditLogDiff` now supports AutoMod related models.
([#2030](https://github.com/Pycord-Development/pycord/pull/2030))
- Added `Interaction.respond` and `Interaction.edit` as shortcut responses.
Expand Down Expand Up @@ -93,6 +94,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2087](https://github.com/Pycord-Development/pycord/pull/2087))
- Typehinted `command_prefix` and `help_command` arguments properly.
([#2099](https://github.com/Pycord-Development/pycord/pull/2099))
- Replace `orjson` support with `msgspec` support.
([#2170](https://github.com/Pycord-Development/pycord/pull/2170))

### Removed

Expand Down Expand Up @@ -151,6 +154,10 @@ These changes are available on the `master` branch, but have not yet been releas
- Fixed type-hinting of `author` property of `ApplicationContext` to include typehinting
of `User` or `Member`.
([#2148](https://github.com/Pycord-Development/pycord/pull/2148))
- Fixed missing `delete_after` parameter in overload type-hinting for `send` method in
`Webhook` class. ([#2156](https://github.com/Pycord-Development/pycord/pull/2156))
- Fixed `ScheduledEvent.creator_id` returning `str` instead of `int`.
([#2162](https://github.com/Pycord-Development/pycord/pull/2162))

## [2.4.1] - 2023-03-20

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Optional Packages

* `PyNaCl <https://pypi.org/project/PyNaCl/>`__ (for voice support)
* `aiodns <https://pypi.org/project/aiodns/>`__, `brotlipy <https://pypi.org/project/brotlipy/>`__, `cchardet <https://pypi.org/project/cchardet/>`__ (for aiohttp speedup)
* `orjson <https://pypi.org/project/orjson/>`__ (for json speedup)
* `msgspec <https://pypi.org/project/msgspec/>`__ (for json speedup)

Please note that while installing voice support on Linux, you must install the following packages via your preferred package manager (e.g. ``apt``, ``dnf``, etc) BEFORE running the above commands:

Expand Down
12 changes: 0 additions & 12 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,6 @@ def to_dict(self) -> dict[str, Any]:
def __eq__(self, other: Any) -> bool:
return isinstance(other, Game) and other.name == self.name

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return hash(self.name)

Expand Down Expand Up @@ -542,9 +539,6 @@ def __eq__(self, other: Any) -> bool:
and other.url == self.url
)

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return hash(self.name)

Expand Down Expand Up @@ -654,9 +648,6 @@ def __eq__(self, other: Any) -> bool:
and other.start == self.start
)

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return hash(self._session_id)

Expand Down Expand Up @@ -829,9 +820,6 @@ def __eq__(self, other: Any) -> bool:
and other.emoji == self.emoji
)

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return hash((self.name, str(self.emoji)))

Expand Down
3 changes: 0 additions & 3 deletions discord/colour.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ def _get_byte(self, byte: int) -> int:
def __eq__(self, other: Any) -> bool:
return isinstance(other, Colour) and self.value == other.value

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __str__(self) -> str:
return f"#{self.value:0>6x}"

Expand Down
3 changes: 0 additions & 3 deletions discord/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ def __repr__(self) -> str:
def __eq__(self, other: Any) -> bool:
return isinstance(other, _EmojiTag) and self.id == other.id

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return self.id >> 22

Expand Down
4 changes: 4 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ class AuditLogAction(Enum):
auto_moderation_block_message = 143
auto_moderation_flag_to_channel = 144
auto_moderation_user_communication_disabled = 145
creator_monetization_request_created = 150
creator_monetization_terms_accepted = 151
onboarding_question_create = 163
onboarding_question_update = 164
onboarding_update = 165
Expand Down Expand Up @@ -492,6 +494,8 @@ def category(self) -> AuditLogActionCategory | None:
AuditLogAction.auto_moderation_block_message: None,
AuditLogAction.auto_moderation_flag_to_channel: None,
AuditLogAction.auto_moderation_user_communication_disabled: None,
AuditLogAction.creator_monetization_request_created: None,
AuditLogAction.creator_monetization_terms_accepted: None,
AuditLogAction.onboarding_question_create: AuditLogActionCategory.create,
AuditLogAction.onboarding_question_update: AuditLogActionCategory.update,
AuditLogAction.onboarding_update: AuditLogActionCategory.update,
Expand Down
3 changes: 0 additions & 3 deletions discord/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ def _from_value(cls, value):
def __eq__(self, other: Any) -> bool:
return isinstance(other, self.__class__) and self.value == other.value

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return hash(self.value)

Expand Down
3 changes: 0 additions & 3 deletions discord/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ def __repr__(self) -> str:
def __eq__(self, other: Any) -> bool:
return isinstance(other, _UserTag) and other.id == self.id

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return hash(self._user)

Expand Down
4 changes: 1 addition & 3 deletions discord/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and other.id == self.id

def __ne__(self, other: object) -> bool:
if isinstance(other, self.__class__):
return other.id != self.id
return True
return not self.__eq__(other)


class Hashable(EqualityComparable):
Expand Down
3 changes: 0 additions & 3 deletions discord/partial_emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ def __eq__(self, other: Any) -> bool:
return self.id == other.id
return False

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return hash((self.id, self.name))

Expand Down
4 changes: 2 additions & 2 deletions discord/scheduled_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ScheduledEvent(Hashable):
The number of users that have marked themselves as interested in the event.
creator_id: Optional[:class:`int`]
The ID of the user who created the event.
It may be ``None`` because events created before October 25th, 2021, haven't
It may be ``None`` because events created before October 25th, 2021 haven't
had their creators tracked.
creator: Optional[:class:`User`]
The resolved user object of who created the event.
Expand Down Expand Up @@ -209,7 +209,7 @@ def __init__(
ScheduledEventStatus, data.get("status")
)
self.subscriber_count: int | None = data.get("user_count", None)
self.creator_id = data.get("creator_id", None)
self.creator_id: int | None = utils._get_as_snowflake(data, "creator_id")
self.creator: Member | None = creator

entity_metadata = data.get("entity_metadata")
Expand Down
3 changes: 0 additions & 3 deletions discord/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ def __str__(self) -> str:
def __eq__(self, other: Any) -> bool:
return isinstance(other, _UserTag) and other.id == self.id

def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
return self.id >> 22

Expand Down
16 changes: 9 additions & 7 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
from .errors import HTTPException, InvalidArgument

try:
import orjson
import msgspec
except ModuleNotFoundError:
HAS_ORJSON = False
HAS_MSGSPEC = False
else:
HAS_ORJSON = True
HAS_MSGSPEC = True


__all__ = (
Expand Down Expand Up @@ -142,6 +142,7 @@ def __get__(self, instance, owner):

from .abc import Snowflake
from .commands.context import AutocompleteContext
from .commands.options import OptionChoice
from .invite import Invite
from .permissions import Permissions
from .template import Template
Expand All @@ -156,6 +157,7 @@ class _RequestLike(Protocol):
else:
cached_property = _cached_property
AutocompleteContext = Any
OptionChoice = Any


T = TypeVar("T")
Expand Down Expand Up @@ -660,12 +662,12 @@ def _bytes_to_base64_data(data: bytes) -> str:
return fmt.format(mime=mime, data=b64)


if HAS_ORJSON:
if HAS_MSGSPEC:

def _to_json(obj: Any) -> str: # type: ignore
return orjson.dumps(obj).decode("utf-8")
return msgspec.json.encode(obj).decode("utf-8")

_from_json = orjson.loads # type: ignore
_from_json = msgspec.json.decode # type: ignore

else:

Expand Down Expand Up @@ -1298,7 +1300,7 @@ def generate_snowflake(dt: datetime.datetime | None = None) -> int:
return int(dt.timestamp() * 1000 - DISCORD_EPOCH) << 22 | 0x3FFFFF


V = Union[Iterable[str], Iterable[int], Iterable[float]]
V = Union[Iterable[OptionChoice], Iterable[str], Iterable[int], Iterable[float]]
AV = Awaitable[V]
Values = Union[V, Callable[[AutocompleteContext], Union[V, AV]], AV]
AutocompleteFunc = Callable[[AutocompleteContext], AV]
Expand Down
2 changes: 2 additions & 0 deletions discord/webhook/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,7 @@ async def send(
thread: Snowflake = MISSING,
thread_name: str | None = None,
wait: Literal[True],
delete_after: float = None,
) -> WebhookMessage:
...

Expand All @@ -1588,6 +1589,7 @@ async def send(
thread: Snowflake = MISSING,
thread_name: str | None = None,
wait: Literal[False] = ...,
delete_after: float = None,
) -> None:
...

Expand Down
12 changes: 12 additions & 0 deletions docs/api/enums.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,18 @@ of :class:`enum.Enum`.

.. versionadded:: 2.5

.. attribute:: creator_monetization_request_created

A creator monetization request was created.

.. versionadded:: 2.5

.. attribute:: creator_monetization_terms_accepted

The creator monetization terms were accepted.

.. versionadded:: 2.5


.. class:: AuditLogActionCategory

Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pylint~=2.17.4
pytest~=7.4.0
pytest-asyncio~=0.21.0
# pytest-order~=1.0.1
mypy~=1.4.0
mypy~=1.4.1
coverage~=7.2
pre-commit==3.3.3
codespell==2.2.5
Expand Down
2 changes: 1 addition & 1 deletion requirements/speed.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
orjson>=3.5.4
msgspec~=0.17.0
aiohttp[speedups]

0 comments on commit 97d8f3e

Please sign in to comment.