Skip to content

Commit 5c2759c

Browse files
committed
Revert assertions requiring data for certain Messages during constructor (Allow flexibility, make constructor stable).
1 parent 05b0dba commit 5c2759c

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

openlcb/message.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,11 @@ def __init__(self, mti, source: NodeID,
2828
data = bytearray()
2929
self.mti = mti
3030
assert isinstance(mti, MTI)
31-
if self.mti in (MTI.Verified_NodeID, MTI.Initialization_Complete):
32-
# Requires node.id in data for these MTIs (See
33-
# 7.3.3.1 and 7.3.3.3 in Message Network Standard)
34-
assert data is not None, \
35-
f"Expected node.id.toArray() for data of {mti}, got {data}"
3631
self.source = source
3732
self.destination = destination # Union[NodeID, None]
3833
self.originalMTI = None # type: Union[int, None]
3934
self.assertTypes()
40-
if not isinstance(data, bytearray):
35+
if not isinstance(data, bytearray): # None becomes bytearray() above
4136
raise TypeError("Expected bytearray, got {}"
4237
.format(type(data).__name__))
4338
self.data = data
@@ -71,6 +66,9 @@ def isGlobal(self) -> bool:
7166
return self.mti.value & 0x0008 == 0
7267

7368
def isAddressed(self) -> bool:
69+
"""Contains destination alias
70+
(not necessarily NodeID)
71+
"""
7472
return self.mti.value & 0x0008 != 0
7573

7674
def __str__(self):

0 commit comments

Comments
 (0)