home-assistant-libs / pychromecast

Library for Python 3 to communicate with the Google Chromecast.
MIT License
2.51k stars 380 forks source link

Change callbacks to be passed status and result #783

Closed emontnemery closed 6 months ago

emontnemery commented 6 months ago

Breaking change

The signature of callbacks called when requests are completed has been changed:

New callback signature:

CallbackType = Callable[[bool, dict | None], None]
"""Signature of optional callback functions supported by methods sending messages.

The callback function will be called with a bool indicating if the message was sent
and an optional response dict.
"""

Change

Callback functions are now called not only on success but also on error. This prevents failing requests from hanging forever. Also, many user facing functions which send messages to the remote device but do not accept a callback now accept a timeout parameter.

Background in PR https://github.com/home-assistant-libs/pychromecast/pull/779

Needs https://github.com/home-assistant-libs/pychromecast/pull/784

MartinHjelmare commented 6 months ago

The breaking change sentence sounds weird. It sounds like the callback is called when a request has changed signature.

MartinHjelmare commented 6 months ago

I think you should document what the callback parameters mean, at least in the PR description and maybe in the readme.