diff --git a/setup.cfg b/setup.cfg index 2e5b6c3..9dbaa73 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,7 +51,7 @@ python_requires = >=3.10 install_requires = aiohttp>=3.8,<4.0 PyJWT>=2.0,<3.0 - paho-mqtt>=1.6,<2 + paho-mqtt>=1.6,<3 [options.package_data] libdeye = py.typed diff --git a/src/libdeye/mqtt_client.py b/src/libdeye/mqtt_client.py index 711c4cf..f91a212 100644 --- a/src/libdeye/mqtt_client.py +++ b/src/libdeye/mqtt_client.py @@ -40,7 +40,7 @@ def __init__( self._mqtt.on_connect = self._mqtt_on_connect self._mqtt.on_message = self._mqtt_on_message self._mqtt.on_disconnect = self._mqtt_on_disconnect - self._subscribers: dict[str, set[Callable[[mqtt.MQTTMessage], None]]] = {} + self._subscribers: dict[str, set[Callable[[Any], None]]] = {} self._pending_commands: list[tuple[str, bytes]] = [] @abstractmethod @@ -64,8 +64,8 @@ def _mqtt_on_connect( _mqtt: mqtt.Client, _userdata: None, _flags: dict[str, int], - _result_code: int, - _properties: mqtt.Properties | None = None, + _result_code: Any, + _properties: Any, ) -> None: for topic, callbacks in self._subscribers.items(): if len(callbacks) > 0: @@ -110,7 +110,7 @@ def _mqtt_on_message( def _subscribe_topic( self, topic: str, - callback: Callable[[mqtt.MQTTMessage], None], + callback: Callable[[Any], None], ) -> Callable[[], None]: if topic not in self._subscribers: self._subscribers[topic] = set() diff --git a/tests/test_mqtt_client.py b/tests/test_mqtt_client.py index a41e996..2d6d263 100644 --- a/tests/test_mqtt_client.py +++ b/tests/test_mqtt_client.py @@ -134,7 +134,7 @@ def test_mqtt_on_connect(self, base_client: MockBaseDeyeMqttClient) -> None: # Call _mqtt_on_connect with patch.object(base_client._mqtt, "subscribe") as mock_subscribe: with patch.object(base_client._mqtt, "publish") as mock_publish: - base_client._mqtt_on_connect(base_client._mqtt, None, {}, 0) + base_client._mqtt_on_connect(base_client._mqtt, None, {}, 0, {}) mock_subscribe.assert_called_once_with(topic1) mock_publish.assert_called_once_with(pending_topic, pending_command) assert len(base_client._pending_commands) == 0 @@ -278,7 +278,7 @@ async def test_set_mqtt_info(self, classic_client: DeyeClassicMqttClient) -> Non assert classic_client._mqtt_host == "test.mqtt.host" assert classic_client._mqtt_ssl_port == 8883 assert classic_client._endpoint == "test_endpoint" - classic_client._mqtt.username_pw_set.assert_called_once_with( + cast(MagicMock, classic_client._mqtt).username_pw_set.assert_called_once_with( "test_user", "test_password" ) @@ -458,7 +458,7 @@ async def test_set_mqtt_info(self, fog_client: DeyeFogMqttClient) -> None: assert fog_client._mqtt_host == "test.mqtt.host" assert fog_client._mqtt_ssl_port == 8883 assert fog_client._topic == "fogcloud/app/test_user/sub" - fog_client._mqtt.username_pw_set.assert_called_once_with( + cast(MagicMock, fog_client._mqtt).username_pw_set.assert_called_once_with( "test_user", "test_password" )