Skip to content

Commit

Permalink
Resolved pylint issues in asyncio_mqtt.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes.Hennecke committed Nov 27, 2023
1 parent cb38786 commit 74c5825
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions mqtt_io/mqtt/asyncio_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

def _map_exception(func: Func) -> Func:
"""
Creates a decorator that wraps a function and maps any raised `MqttError` exception to a `MQTTException`.
Creates a decorator that wraps a function and maps any raised `MqttError`
exception to a `MQTTException`.
:param func: The function to be wrapped.
:type func: Func
Expand All @@ -37,7 +38,8 @@ def _map_exception(func: Func) -> Func:
@wraps(func)
async def inner(*args: Any, **kwargs: Any) -> Any:
"""
Decorator for asynchronous functions that catches `MqttError` exceptions and raises `MQTTException` instead.
Decorator for asynchronous functions that catches `MqttError` exceptions
and raises `MQTTException` instead.
Parameters:
func (Callable): The function to be decorated.
Expand Down Expand Up @@ -117,10 +119,10 @@ async def connect(self, timeout: int = 10) -> None:
async def disconnect(self) -> None:
"""
This function is an asynchronous method that handles the disconnection of the client.
Parameters:
self: The current instance of the class.
Returns:
None
"""
Expand All @@ -135,8 +137,10 @@ async def subscribe(self, topics: List[Tuple[str, int]]) -> None:
Subscribe to the given list of topics.
Args:
topics (List[Tuple[str, int]]): A list of tuples representing the topics to subscribe to.
Each tuple should contain a string representing the topic name and an integer representing the QoS level.
topics (List[Tuple[str, int]]): A list of tuples representing the topics
to subscribe to.
Each tuple should contain a string representing the topic name and
an integer representing the QoS level.
Returns:
None: This function does not return anything.
Expand Down Expand Up @@ -191,7 +195,7 @@ def _on_message(
def message_queue(self) -> "asyncio.Queue[MQTTMessage]":
"""
Returns the message queue for receiving MQTT messages.
:return: The message queue for receiving MQTT messages.
:rtype: asyncio.Queue[MQTTMessage]
"""
Expand Down
5 changes: 3 additions & 2 deletions mqtt_io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ async def get_sensor_value(
A decorator that applies exponential backoff to the function `get_sensor_value`.
Parameters:
sensor_module (GenericSensor): The sensor module to use for getting the sensor value.
sensor_module (GenericSensor): The sensor module to use for getting
the sensor value.
sens_conf (ConfigType): The configuration for the sensor.
Returns:
Expand Down Expand Up @@ -792,7 +793,7 @@ async def _mqtt_publish(self, msg: MQTTMessageSend, wait: bool = True) -> None:

if msg.payload is None:
_LOG.debug("Publishing MQTT message on topic %r with no payload", msg.topic)
elif isinstance(msg.payload, bytes) or isinstance(msg.payload, bytearray):
elif isinstance(msg.payload, (bytearray, bytes)):
try:
payload = msg.payload.decode("utf8")
except UnicodeDecodeError:
Expand Down

0 comments on commit 74c5825

Please sign in to comment.