diff --git a/CHANGELOG.md b/CHANGELOG.md index 512bdbe4d1..c096cc08c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/discord/client.py b/discord/client.py index 8fcb46e942..a016c15957 100644 --- a/discord/client.py +++ b/discord/client.py @@ -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. """ diff --git a/discord/gateway.py b/discord/gateway.py index 9d59edc3d1..b0eb364601 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -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 diff --git a/discord/shard.py b/discord/shard.py index 8e84f5b8f2..fd6a08a047 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -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: diff --git a/discord/utils.py b/discord/utils.py index 1a5f96cf46..b48381edf3 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -56,7 +56,6 @@ Iterator, Literal, Mapping, - NewType, Protocol, Sequence, TypeVar, @@ -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") diff --git a/requirements/dev.txt b/requirements/dev.txt index 83961bbfdc..83326ccb3e 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -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 diff --git a/requirements/docs.txt b/requirements/docs.txt index 335b420074..d1adea5fc0 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -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