Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Python 2.x compatibility from socket client #801

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions pychromecast/socket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import select
import socket
import ssl
import sys
import threading
import time
from collections import defaultdict
Expand Down Expand Up @@ -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")


def _is_ssl_timeout(exc):
Expand Down