Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Aarni Koskela <akx@iki.fi>
  • Loading branch information
PierreF and akx authored Jan 10, 2024
1 parent a2a4840 commit f027612
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/paho/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def __del__(self):

@property
def host(self) -> str:
"Host we try to connect to. If don't yet called connect() return empty string"
"""Host to connect to. If `connect()` hasn't been called yet, returns an empty string."""
return self._host

@host.setter
Expand All @@ -635,19 +635,19 @@ def host(self, value: str) -> None:
Update host. This will only be used on future (re)connection. You should probably
use reconnect() to update the connection if established.
"""
if value is None or len(value) == 0:
if not value:
raise ValueError("Invalid host.")
self._host = value

@property
def port(self) -> int:
"TCP port we try to connect to."
"""Broker TCP port to connect to."""
return self._port

@port.setter
def port(self, value: int) -> None:
"""
Update post. This will only be used on future (re)connection. You should probably
Update port. This will only be used on future (re)connection. You should probably
use reconnect() to update the connection if established.
"""
if value <= 0:
Expand All @@ -656,12 +656,12 @@ def port(self, value: int) -> None:

@property
def keepalive(self) -> int:
"Keepalive in seconds used by the client "
"""Client keepalive interval (in seconds)."""
return self._keepalive

@keepalive.setter
def keepalive(self, value: int) -> None:
"Update keepalive. It's behavior is undefined if the connection is already open"
"""Update the client keepalive interval. This may not be called if the connection is already open."""
if self._sock is not None:
# The issue here is that the previous value of keepalive matter to possibly
# sent ping packet.
Expand All @@ -678,7 +678,7 @@ def keepalive(self, value: int) -> None:

@property
def transport(self) -> str:
'Transport used for the connection, could be "tcp" or "websockets".'
"""Transport method used for the connection."""
return self._transport

@transport.setter
Expand All @@ -696,12 +696,12 @@ def transport(self, value: str) -> None:

@property
def protocol(self) -> int:
"Protocol version used (MQTT v3, MQTT v3.11, MQTTv5)"
"""Protocol version used (MQTT v3, MQTT v3.11, MQTTv5)"""
return self.protocol

@property
def connect_timeout(self) -> float:
"Timeout used to establish the TCP (& TLS / websocket if enabled) in seconds"
"""Connection establishment timeout in seconds"""
return self._connect_timeout

@connect_timeout.setter
Expand All @@ -714,7 +714,7 @@ def connect_timeout(self, value: float):

@property
def username(self) -> str | None:
"Return the username use to connect to MQTT broken or None if not credenials are used."
"""The username used to connect to the MQTT broker, or None if no username is used."""
if self._username is None:
return None
return self._username.decode("utf-8")
Expand All @@ -732,7 +732,7 @@ def username(self, value: str | None) -> None:

@property
def password(self) -> str | None:
"Return the password use to connect to MQTT broken or None if not password are used."
"""The password used to connect to the MQTT broker, or None if no password is used."""
if self._password is None:
return None
return self._password.decode("utf-8")
Expand All @@ -750,7 +750,7 @@ def password(self, value: str | None) -> None:

@property
def max_inflight_messages(self) -> int:
"Maximum number of message with QoS > 0 that can be part way through their network flow at once"
"""Maximum number of messages with QoS > 0 that can be partway through the network flow at once"""
return self._max_inflight_messages

@max_inflight_messages.setter
Expand Down Expand Up @@ -791,15 +791,15 @@ def max_queued_messages(self, value: int) -> None:

@property
def will_topic(self) -> str | None:
"Return the topic will is sent to on unexpected disconnect, or None if will isn't set"
"""The topic name a will message is sent to when disconnecting unexpectedly. None if a will shall not be sent."""
if self._will_topic is None:
return None

return self._will_topic.decode("utf-8")

@property
def will_payload(self) -> bytes | None:
"Return the payload will send on unexpected disconnect, or None if will isn't set"
"""The payload for the will message that is sent when disconnecting unexpectedly. None if a will shall not be sent."""
if self._will_topic is None:
return None

Expand Down

0 comments on commit f027612

Please sign in to comment.