Skip to content

Commit

Permalink
refactor: Bump paho-mqtt, ruff, and mypy; #286
Browse files Browse the repository at this point in the history
  • Loading branch information
empicano committed Jun 5, 2024
1 parent f1a6139 commit 6b2527d
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 96 deletions.
12 changes: 6 additions & 6 deletions aiomqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ def __init__( # noqa: C901, PLR0912, PLR0913, PLR0915
# Create the underlying paho-mqtt client instance
self._client: mqtt.Client = mqtt.Client(
callback_api_version=CallbackAPIVersion.VERSION1,
client_id=identifier, # type: ignore[arg-type]
protocol=protocol,
client_id=identifier,
protocol=protocol.value,
clean_session=clean_session,
transport=transport,
reconnect_on_failure=False,
Expand Down Expand Up @@ -371,9 +371,9 @@ async def subscribe( # noqa: PLR0913
if result != mqtt.MQTT_ERR_SUCCESS or mid is None:
raise MqttCodeError(result, "Could not subscribe to topic")
# Create future for when the on_subscribe callback is called
callback_result: asyncio.Future[
tuple[int, ...] | list[ReasonCode]
] = asyncio.Future()
callback_result: asyncio.Future[tuple[int, ...] | list[ReasonCode]] = (
asyncio.Future()
)
with self._pending_call(mid, callback_result, self._pending_subscribes):
# Wait for callback_result
return await self._wait_for(callback_result, timeout=timeout)
Expand All @@ -400,7 +400,7 @@ async def unsubscribe(
**kwargs: Additional keyword arguments to pass to paho-mqtt's unsubscribe
method.
"""
result, mid = self._client.unsubscribe(topic, properties, *args, **kwargs) # type: ignore[arg-type]
result, mid = self._client.unsubscribe(topic, properties, *args, **kwargs)
# Early out on error
if result != mqtt.MQTT_ERR_SUCCESS or mid is None:
raise MqttCodeError(result, "Could not unsubscribe from topic")
Expand Down
5 changes: 2 additions & 3 deletions aiomqtt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __str__(self) -> str:
if isinstance(self.rc, ReasonCode):
return f"[code:{self.rc.value}] {self.rc!s}"
if isinstance(self.rc, int):
return f"[code:{self.rc}] {mqtt.error_string(self.rc)}" # type: ignore[arg-type]
return f"[code:{self.rc}] {mqtt.error_string(self.rc)}"
return f"[code:{self.rc}] {super().__str__()}"


Expand All @@ -37,8 +37,7 @@ def __init__(self, rc: int | ReasonCode) -> None:
super().__init__(rc, msg)


class MqttReentrantError(MqttError):
...
class MqttReentrantError(MqttError): ...


_CONNECT_RC_STRINGS: dict[int, str] = {
Expand Down
Loading

0 comments on commit 6b2527d

Please sign in to comment.