Skip to content

Commit

Permalink
Merge branch 'master' into soundboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Paillat-dev authored Dec 10, 2024
2 parents 9ba044d + 52ee8fb commit a6cb39f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2624](https://github.com/Pycord-Development/pycord/pull/2624))
- Fixed `AttributeError` when accessing `Member.guild_permissions` for user installed
apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650))
- Fixed type annotations of cached properties.
([#2635](https://github.com/Pycord-Development/pycord/issues/2635))

### Changed

Expand Down
3 changes: 2 additions & 1 deletion discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def _handle_ready(self) -> None:

@property
def latency(self) -> float:
"""Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds.
"""Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds. If no websocket
is present, this returns ``nan``, and if no heartbeat has been received yet, this returns ``float('inf')``.
This could be referred to as the Discord WebSocket protocol latency.
"""
Expand Down
4 changes: 3 additions & 1 deletion discord/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,9 @@ async def received_message(self, msg, /):

@property
def latency(self) -> float:
"""Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds."""
"""Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds. If no heartbeat
has been received yet this returns ``float('inf')``.
"""
heartbeat = self._keep_alive
return float("inf") if heartbeat is None else heartbeat.latency

Expand Down
4 changes: 3 additions & 1 deletion discord/shard.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ async def connect(self) -> None:

@property
def latency(self) -> float:
"""Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds for this shard."""
"""Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds for this shard. If no heartbeat
has been received yet this returns ``float('inf')``.
"""
return self._parent.ws.latency

def is_ws_ratelimited(self) -> bool:
Expand Down
3 changes: 1 addition & 2 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
Iterator,
Literal,
Mapping,
NewType,
Protocol,
Sequence,
TypeVar,
Expand Down Expand Up @@ -151,7 +150,7 @@ def __get__(self, instance, owner):
class _RequestLike(Protocol):
headers: Mapping[str, Any]

cached_property = NewType("cached_property", property)
cached_property = property

P = ParamSpec("P")

Expand Down
4 changes: 2 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-r _.txt
pylint~=3.3.1
pytest~=8.3.3
pylint~=3.3.2
pytest~=8.3.4
pytest-asyncio~=0.23.8
# pytest-order~=1.0.1
mypy~=1.13.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ sphinxext-opengraph==0.9.1
sphinx-copybutton==0.5.2
furo==2024.8.6
sphinx-autodoc-typehints==2.2.3
sphinx-intl==2.3.0
sphinx-intl==2.3.1
typing_extensions==4.12.2
levenshtein==0.26.1

0 comments on commit a6cb39f

Please sign in to comment.