Skip to content

Commit

Permalink
Improve multiline text.
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic committed Nov 13, 2023
1 parent 399820f commit 9e9d3f1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 26 deletions.
14 changes: 8 additions & 6 deletions pyplumio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def __init__(self, host: str, port: int, **kwargs):
self.host = host
self.port = port

def __repr__(self):
"""Return a string representation of the class."""
def __repr__(self) -> str:
"""Return a serializable string representation."""
return (
f"TcpConnection(host={self.host}, port={self.port}, kwargs={self._kwargs})"
)
Expand All @@ -157,11 +157,13 @@ def __init__(self, device: str, baudrate: int = 115200, **kwargs):
self.device = device
self.baudrate = baudrate

def __repr__(self):
"""Return a string representation of the class."""
def __repr__(self) -> str:
"""Return a serializable string representation."""
return (
f"SerialConnection(device={self.device}, baudrate={self.baudrate}, "
+ f"kwargs={self._kwargs})"
"SerialConnection("
f"device={self.device}, "
f"baudrate={self.baudrate}, "
f"kwargs={self._kwargs})"
)

@timeout(CONNECT_TIMEOUT)
Expand Down
11 changes: 7 additions & 4 deletions pyplumio/devices/ecomax.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,13 @@ async def _handle_ecomax_parameters(
description = ECOMAX_PARAMETERS[product.type][index]
except IndexError:
_LOGGER.warning(
"Encountered unknown ecoMAX parameter (%i). Your device isn't fully"
+ "compatible with this software and might not work properly. "
+ "Please visit the issue tracker and open a feature "
+ "request to support your device",
(
"Encountered unknown ecoMAX parameter (%i). Your device isn't "
"fully compatible with this software and "
"might not work properly."
"Please visit the issue tracker and open a feature "
"request to support your device"
),
index,
)
return False
Expand Down
11 changes: 7 additions & 4 deletions pyplumio/devices/mixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ async def _handle_parameters(
description = MIXER_PARAMETERS[product.type][index]
except IndexError:
_LOGGER.warning(
"Encountered unknown mixer parameter (%i). Your device isn't fully"
+ "compatible with this software and might not work properly. "
+ "Please visit the issue tracker and open a feature "
+ "request to support your device",
(
"Encountered unknown mixer parameter (%i). Your device isn't "
"fully compatible with this software and "
"might not work properly."
"Please visit the issue tracker and open a feature "
"request to support your device"
),
index,
)
return False
Expand Down
26 changes: 16 additions & 10 deletions tests/frames/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,25 @@ def test_message_setter():

def test_request_repr(request_frame: Request) -> None:
"""Test a request class serialiazible representation."""
repr_string = (
"RequestFrame(recipient=<DeviceType.ALL: 0>, "
+ "sender=<DeviceType.ECONET: 86>, sender_type=48, econet_version=5, "
+ "message=bytearray(b''), data={})"
assert repr(request_frame) == (
"RequestFrame("
"recipient=<DeviceType.ALL: 0>, "
"sender=<DeviceType.ECONET: 86>, "
"sender_type=48, "
"econet_version=5, "
"message=bytearray(b''), "
"data={})"
)
assert repr(request_frame) == repr_string


def test_response_repr(response_frame: Response) -> None:
"""Test a response class serialiazible representation."""
repr_string = (
"ResponseFrame(recipient=<DeviceType.ALL: 0>, "
+ "sender=<DeviceType.ECONET: 86>, sender_type=48, econet_version=5, "
+ "message=bytearray(b''), data={})"
assert repr(response_frame) == (
"ResponseFrame("
"recipient=<DeviceType.ALL: 0>, "
"sender=<DeviceType.ECONET: 86>, "
"sender_type=48, "
"econet_version=5, "
"message=bytearray(b''), "
"data={})"
)
assert repr(response_frame) == repr_string
4 changes: 2 additions & 2 deletions tests/helpers/test_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def test_parameter_repr(parameter: Parameter) -> None:
"""Test a parameter representation."""
assert repr(parameter) == (
"TestParameter(device=EcoMAX, "
+ "description=ParameterDescription(name='test_parameter', "
+ "unit_of_measurement=None), value=1, min_value=0, max_value=5)"
"description=ParameterDescription(name='test_parameter', "
"unit_of_measurement=None), value=1, min_value=0, max_value=5)"
)


Expand Down

0 comments on commit 9e9d3f1

Please sign in to comment.