Only try remove callbacks when not None (#268)

This commit is contained in:
Jesse Hills 2022-10-03 12:32:13 +13:00 committed by GitHub
parent fa41b09232
commit a6f18ae9df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -421,8 +421,8 @@ class APIClient:
)
def unsub() -> None:
assert self._connection is not None
self._connection.remove_message_callback(on_msg)
if self._connection is not None:
self._connection.remove_message_callback(on_msg)
return unsub
@ -442,8 +442,8 @@ class APIClient:
)
def unsub() -> None:
assert self._connection is not None
self._connection.remove_message_callback(on_msg)
if self._connection is not None:
self._connection.remove_message_callback(on_msg)
return unsub
@ -474,8 +474,8 @@ class APIClient:
)
def unsub() -> None:
assert self._connection is not None
self._connection.remove_message_callback(on_msg)
if self._connection is not None:
self._connection.remove_message_callback(on_msg)
try:
async with async_timeout.timeout(timeout):
@ -633,7 +633,9 @@ class APIClient:
)
async def stop_notify() -> None:
assert self._connection is not None
if self._connection is None:
return
self._connection.remove_message_callback(on_msg)
self._check_authenticated()