Skip to content

Commit

Permalink
Merge branch 'master' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby authored Jul 14, 2023
2 parents 63c22be + 9926ef5 commit dcf8f34
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 40 deletions.
5 changes: 4 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
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 @@ -425,6 +425,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

@property
def category(self) -> AuditLogActionCategory | None:
Expand Down Expand Up @@ -485,6 +487,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,
}
return lookup[self]

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
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
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
12 changes: 6 additions & 6 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 @@ -662,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
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 dcf8f34

Please sign in to comment.