@@ -59,10 +59,10 @@ def encode(self):
5959 :returns: The byte encoded message
6060 """
6161 result = struct .pack (">H" , self .address )
62- if self .value :
62+ if self .value : # pragma: no cover
6363 result += _turn_coil_on
6464 else :
65- result += _turn_coil_off
65+ result += _turn_coil_off # pragma: no cover
6666 return result
6767
6868 def decode (self , data ):
@@ -73,7 +73,7 @@ def decode(self, data):
7373 self .address , value = struct .unpack (">HH" , data )
7474 self .value = value == ModbusStatus .ON
7575
76- async def execute (self , context ):
76+ async def execute (self , context ): # pragma: no cover
7777 """Run a write coil request against a datastore.
7878
7979 :param context: The datastore to request from
@@ -97,10 +97,7 @@ def get_response_pdu_size(self):
9797 return 1 + 2 + 2
9898
9999 def __str__ (self ):
100- """Return a string representation of the instance.
101-
102- :return: A string representation of the instance
103- """
100+ """Return a string representation of the instance."""
104101 return f"WriteCoilRequest({ self .address } , { self .value } ) => "
105102
106103
@@ -129,10 +126,10 @@ def encode(self):
129126 :return: The byte encoded message
130127 """
131128 result = struct .pack (">H" , self .address )
132- if self .value :
129+ if self .value : # pragma: no cover
133130 result += _turn_coil_on
134131 else :
135- result += _turn_coil_off
132+ result += _turn_coil_off # pragma: no cover
136133 return result
137134
138135 def decode (self , data ):
@@ -167,15 +164,15 @@ class WriteMultipleCoilsRequest(ModbusPDU):
167164 function_code_name = "write_coils"
168165 _rtu_byte_count_pos = 6
169166
170- def __init__ (self , address = None , values = None , slave = None , transaction = 0 , skip_encode = 0 ):
167+ def __init__ (self , address = 0 , values = None , slave = None , transaction = 0 , skip_encode = 0 ):
171168 """Initialize a new instance.
172169
173170 :param address: The starting request address
174171 :param values: The values to write
175172 """
176173 ModbusPDU .__init__ (self , slave , transaction , skip_encode )
177174 self .address = address
178- if values is None :
175+ if values is None : # pragma: no cover
179176 values = []
180177 elif not hasattr (values , "__iter__" ):
181178 values = [values ]
@@ -202,7 +199,7 @@ def decode(self, data):
202199 values = unpack_bitstring (data [5 :])
203200 self .values = values [:count ]
204201
205- async def execute (self , context ):
202+ async def execute (self , context ): # pragma: no cover
206203 """Run a write coils request against a datastore.
207204
208205 :param context: The datastore to request from
@@ -222,15 +219,8 @@ async def execute(self, context):
222219 return WriteMultipleCoilsResponse (self .address , count )
223220
224221 def __str__ (self ):
225- """Return a string representation of the instance.
226-
227- :returns: A string representation of the instance
228- """
229- params = (self .address , len (self .values ))
230- return (
231- "WriteNCoilRequest (%d) => %d " # pylint: disable=consider-using-f-string
232- % params
233- )
222+ """Return a string representation of the instance."""
223+ return f"WriteNCoilRequest ({ self .address } ) => { len (self .values )} "
234224
235225 def get_response_pdu_size (self ):
236226 """Get response pdu size.
@@ -275,8 +265,5 @@ def decode(self, data):
275265 self .address , self .count = struct .unpack (">HH" , data )
276266
277267 def __str__ (self ):
278- """Return a string representation of the instance.
279-
280- :returns: A string representation of the instance
281- """
268+ """Return a string representation of the instance."""
282269 return f"WriteNCoilResponse({ self .address } , { self .count } )"
0 commit comments