Simplifies latency property getter logic

Refactors the conditional check to use getattr with a default value,
reducing code complexity while maintaining the same functionality
This commit is contained in:
Slipstream 2025-06-11 15:33:58 -06:00
parent 592653cccd
commit 071e01cd87
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -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|