From 1db02c43bfea5011aedfb5f1aa6c03e7c88bcb80 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 26 Jan 2024 13:08:19 +0100 Subject: [PATCH] Remove Python 2.x compatibility from socket client (#801) * Remove Python 2.x compatibility from socket client * Update socket_client.py --- pychromecast/socket_client.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pychromecast/socket_client.py b/pychromecast/socket_client.py index a4ec9ef2b..7d742bc9b 100644 --- a/pychromecast/socket_client.py +++ b/pychromecast/socket_client.py @@ -15,7 +15,6 @@ import select import socket import ssl -import sys import threading import time from collections import defaultdict @@ -106,17 +105,9 @@ def _message_to_string(message, data=None): ) -if sys.version_info >= (3, 0): - - def _json_to_payload(data): - """Encodes a python value into JSON format.""" - return json.dumps(data, ensure_ascii=False).encode("utf8") - -else: - - def _json_to_payload(data): - """Encodes a python value into JSON format.""" - return json.dumps(data, ensure_ascii=False) +def _json_to_payload(data: dict) -> bytes: + """Encodes a python value into JSON format.""" + return json.dumps(data, ensure_ascii=False).encode("utf8") @dataclass(frozen=True)