Skip to content

Commit 82c7eae

Browse files
authored
LGTM, thanks.
1 parent 53e645e commit 82c7eae

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

pymodbus/events.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,25 @@
55
(the high-order bit) in each byte. It may be further defined by bit 6.
66
"""
77
# pylint: disable=missing-type-doc
8-
from pymodbus.exceptions import NotImplementedException, ParameterException
8+
from abc import ABC, abstractmethod
9+
10+
from pymodbus.exceptions import ParameterException
911
from pymodbus.utilities import pack_bitstring, unpack_bitstring
1012

1113

12-
class ModbusEvent:
14+
class ModbusEvent(ABC):
1315
"""Define modbus events."""
1416

15-
def encode(self):
16-
"""Encode the status bits to an event message.
17-
18-
:raises NotImplementedException:
19-
"""
20-
raise NotImplementedException
17+
@abstractmethod
18+
def encode(self) -> bytes:
19+
"""Encode the status bits to an event message."""
2120

21+
@abstractmethod
2222
def decode(self, event):
2323
"""Decode the event message to its status bits.
2424
2525
:param event: The event to decode
26-
:raises NotImplementedException:
2726
"""
28-
raise NotImplementedException
2927

3028

3129
class RemoteReceiveEvent(ModbusEvent):

test/sub_current/test_device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ModbusDeviceIdentification,
77
ModbusPlusStatistics,
88
)
9-
from pymodbus.events import ModbusEvent, RemoteReceiveEvent
9+
from pymodbus.events import RemoteReceiveEvent
1010

1111

1212
# ---------------------------------------------------------------------------#
@@ -281,7 +281,7 @@ def test_modbus_control_block_invalid_diagnostic(self):
281281
def test_clearing_control_events(self):
282282
"""Test adding and clearing modbus events."""
283283
assert self.control.Events == []
284-
event = ModbusEvent()
284+
event = RemoteReceiveEvent()
285285
self.control.addEvent(event)
286286
assert self.control.Events == [event]
287287
assert self.control.Counter.Event == 1

test/sub_current/test_events.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,15 @@
44
from pymodbus.events import (
55
CommunicationRestartEvent,
66
EnteredListenModeEvent,
7-
ModbusEvent,
87
RemoteReceiveEvent,
98
RemoteSendEvent,
109
)
11-
from pymodbus.exceptions import NotImplementedException, ParameterException
10+
from pymodbus.exceptions import ParameterException
1211

1312

1413
class TestEvents:
1514
"""Unittest for the pymodbus.device module."""
1615

17-
def test_modbus_event_base_class(self):
18-
"""Test modbus event base class."""
19-
event = ModbusEvent()
20-
with pytest.raises(NotImplementedException):
21-
event.encode()
22-
with pytest.raises(NotImplementedException):
23-
event.decode(None)
24-
2516
def test_remote_receive_event(self):
2617
"""Test remove receive event."""
2718
event = RemoteReceiveEvent()

0 commit comments

Comments
 (0)