From 071e01cd8791f22513cfc38eab22ae499003a250 Mon Sep 17 00:00:00 2001 From: Slipstream Date: Wed, 11 Jun 2025 15:33:58 -0600 Subject: [PATCH] Simplifies latency property getter logic Refactors the conditional check to use getattr with a default value, reducing code complexity while maintaining the same functionality --- disagreement/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/disagreement/client.py b/disagreement/client.py index cf3d52b..e2ff88f 100644 --- a/disagreement/client.py +++ b/disagreement/client.py @@ -415,9 +415,8 @@ class Client: @property def latency_ms(self) -> Optional[float]: """Returns the gateway latency in milliseconds, or ``None`` if unavailable.""" - if self._gateway and self._gateway.latency_ms is not None: - return round(self._gateway.latency_ms, 2) - return None + latency = getattr(self._gateway, "latency_ms", None) + return round(latency, 2) if latency is not None else None async def wait_until_ready(self) -> None: """|coro|