-
Notifications
You must be signed in to change notification settings - Fork 380
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
Add type annotations to socket_client.py #805
Conversation
8772557
to
624ec13
Compare
else: | ||
retry_log_fun( | ||
"[%s(%s):%s] Failed to connect, retrying in %.1fs", | ||
self.fn or "", | ||
self.host, | ||
self.port, | ||
self.retry_wait, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have been cleaned up as part of #556
pychromecast/socket_client.py
Outdated
msg.namespace = namespace | ||
msg.payload_utf8 = _json_to_payload(data) | ||
msg.payload_utf8 = _json_to_payload(data) # type: ignore[assignment] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code works, but violates the typing of CastMessage
which says CastMessage.payload_utf8
should be a str
.
Edit:
After some debugging of the pure Python version of protobuf, it turns our that the bytes
provided by us is decoded to a str
here: https://github.com/protocolbuffers/protobuf/blob/1d6ac5979b909a222db45cb154f0be3a31828324/python/google/protobuf/internal/type_checkers.py#L189, and then encoded again here: https://github.com/protocolbuffers/protobuf/blob/1d6ac5979b909a222db45cb154f0be3a31828324/python/google/protobuf/internal/encoder.py#L678
This is clearly a waste of CPU time, fixed in PR #806
There's a merge conflict. |
No description provided.