Skip to content

Commit bce10d3

Browse files
authored
fix flake8 errors
1 parent dfa3062 commit bce10d3

File tree

6 files changed

+53
-51
lines changed

6 files changed

+53
-51
lines changed

examples/multi_client_modify_shared_registers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def update_register_definitions(register_definitions, *servers):
135135
else:
136136
curr_values = value
137137
server.set_ireg(address=address, value=curr_values)
138-
138+
139139
await asyncio.sleep(5)
140140

141141

umodbus/asynchronous/serial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def get_request(self,
9898
async def _uart_read_frame(self,
9999
timeout: Optional[int] = None) -> bytearray:
100100
"""@see RTUServer._uart_read_frame"""
101-
t1char_ms = max(2, self._t1char//1000)
101+
t1char_ms = max(2, self._t1char // 1000)
102102

103103
# Wait here till the next frame starts
104104
while not self._uart.any():

umodbus/compat_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
from socket import inet_ntop
1515
except ImportError:
1616
import socket
17+
1718
def inet_ntop(type: int, packed_ip: bytes) -> str:
1819
if type == socket.AF_INET:
1920
return ".".join(map(str, packed_ip))
2021
elif type == socket.AF_INET6:
21-
iterator = zip(*[iter(packed_ip)]*2)
22+
iterator = zip(*[iter(packed_ip)] * 2)
2223
ipv6_addr = []
2324
for high, low in iterator:
2425
ipv6_addr.append(f"{high << 8 | low:04x}")

umodbus/functions.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def read_discrete_inputs(starting_address: int, quantity: int) -> bytes:
5151
raise ValueError('Invalid number of discrete inputs')
5252

5353
return struct.pack('>BHH',
54-
Const.READ_DISCRETE_INPUTS,
55-
starting_address,
56-
quantity)
54+
Const.READ_DISCRETE_INPUTS,
55+
starting_address,
56+
quantity)
5757

5858

5959
def read_holding_registers(starting_address: int, quantity: int) -> bytes:
@@ -72,9 +72,9 @@ def read_holding_registers(starting_address: int, quantity: int) -> bytes:
7272
raise ValueError('Invalid number of holding registers')
7373

7474
return struct.pack('>BHH',
75-
Const.READ_HOLDING_REGISTERS,
76-
starting_address,
77-
quantity)
75+
Const.READ_HOLDING_REGISTERS,
76+
starting_address,
77+
quantity)
7878

7979

8080
def read_input_registers(starting_address: int, quantity: int) -> bytes:
@@ -93,9 +93,9 @@ def read_input_registers(starting_address: int, quantity: int) -> bytes:
9393
raise ValueError('Invalid number of input registers')
9494

9595
return struct.pack('>BHH',
96-
Const.READ_INPUT_REGISTER,
97-
starting_address,
98-
quantity)
96+
Const.READ_INPUT_REGISTER,
97+
starting_address,
98+
quantity)
9999

100100

101101
def write_single_coil(output_address: int,
@@ -121,9 +121,9 @@ def write_single_coil(output_address: int,
121121
output_value = 0x0000
122122

123123
return struct.pack('>BHH',
124-
Const.WRITE_SINGLE_COIL,
125-
output_address,
126-
output_value)
124+
Const.WRITE_SINGLE_COIL,
125+
output_address,
126+
output_value)
127127

128128

129129
def write_single_register(register_address: int,
@@ -145,9 +145,9 @@ def write_single_register(register_address: int,
145145
fmt = 'h' if signed else 'H'
146146

147147
return struct.pack('>BH' + fmt,
148-
Const.WRITE_SINGLE_REGISTER,
149-
register_address,
150-
register_value)
148+
Const.WRITE_SINGLE_REGISTER,
149+
register_address,
150+
register_value)
151151

152152

153153
def write_multiple_coils(starting_address: int,
@@ -184,11 +184,11 @@ def write_multiple_coils(starting_address: int,
184184
byte_count += 1
185185

186186
return struct.pack('>BHHB' + fmt,
187-
Const.WRITE_MULTIPLE_COILS,
188-
starting_address,
189-
quantity,
190-
byte_count,
191-
*output_value)
187+
Const.WRITE_MULTIPLE_COILS,
188+
starting_address,
189+
quantity,
190+
byte_count,
191+
*output_value)
192192

193193

194194
def write_multiple_registers(starting_address: int,
@@ -215,11 +215,11 @@ def write_multiple_registers(starting_address: int,
215215
fmt = ('h' if signed else 'H') * quantity
216216

217217
return struct.pack('>BHHB' + fmt,
218-
Const.WRITE_MULTIPLE_REGISTERS,
219-
starting_address,
220-
quantity,
221-
byte_count,
222-
*register_values)
218+
Const.WRITE_MULTIPLE_REGISTERS,
219+
starting_address,
220+
quantity,
221+
byte_count,
222+
*register_values)
223223

224224

225225
def validate_resp_data(data: bytes,
@@ -314,9 +314,9 @@ def response(function_code: int,
314314

315315
fmt = 'B' * len(output_value)
316316
return struct.pack('>BB' + fmt,
317-
function_code,
318-
((len(value_list) - 1) // 8) + 1,
319-
*output_value)
317+
function_code,
318+
((len(value_list) - 1) // 8) + 1,
319+
*output_value)
320320

321321
elif function_code in [Const.READ_HOLDING_REGISTERS,
322322
Const.READ_INPUT_REGISTER]:
@@ -333,23 +333,23 @@ def response(function_code: int,
333333
fmt += 'h' if s else 'H'
334334

335335
return struct.pack('>BB' + fmt,
336-
function_code,
337-
quantity * 2,
338-
*value_list)
336+
function_code,
337+
quantity * 2,
338+
*value_list)
339339

340340
elif function_code in [Const.WRITE_SINGLE_COIL,
341341
Const.WRITE_SINGLE_REGISTER]:
342342
return struct.pack('>BHBB',
343-
function_code,
344-
request_register_addr,
345-
*request_data)
343+
function_code,
344+
request_register_addr,
345+
*request_data)
346346

347347
elif function_code in [Const.WRITE_MULTIPLE_COILS,
348348
Const.WRITE_MULTIPLE_REGISTERS]:
349349
return struct.pack('>BHH',
350-
function_code,
351-
request_register_addr,
352-
request_register_qty)
350+
function_code,
351+
request_register_addr,
352+
request_register_qty)
353353

354354
return b''
355355

umodbus/modbus.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -895,22 +895,22 @@ def setup_registers(self,
895895

896896
if reg_type == Const.COILS:
897897
self.add_coil(address=address,
898-
value=value,
899-
on_set_cb=on_set_cb,
900-
on_get_cb=on_get_cb)
898+
value=value,
899+
on_set_cb=on_set_cb,
900+
on_get_cb=on_get_cb)
901901
elif reg_type == Const.HREGS:
902902
self.add_hreg(address=address,
903-
value=value,
904-
on_set_cb=on_set_cb,
905-
on_get_cb=on_get_cb)
903+
value=value,
904+
on_set_cb=on_set_cb,
905+
on_get_cb=on_get_cb)
906906
elif reg_type == Const.ISTS:
907907
self.add_ist(address=address,
908-
value=value,
909-
on_get_cb=on_get_cb) # only getter
908+
value=value,
909+
on_get_cb=on_get_cb) # only getter
910910
elif reg_type == Const.IREGS:
911911
self.add_ireg(address=address,
912-
value=value,
913-
on_get_cb=on_get_cb) # only getter
912+
value=value,
913+
on_get_cb=on_get_cb) # only getter
914914

915915
try:
916916
extra_callbacks = registers["META"]

umodbus/tcp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
# in case inet_ntop not natively supported on Micropython
2727
from .compat_utils import inet_ntop
2828

29+
2930
class ModbusTCP(Modbus):
3031
"""Modbus TCP client class"""
3132
def __init__(self, addr_list: Optional[List[int]] = None):
@@ -361,7 +362,7 @@ def send_exception_response(self,
361362

362363
def _close_client_sockets(self) -> None:
363364
"""
364-
Closes the old client sockets (if any) and
365+
Closes the old client sockets (if any) and
365366
calls the on_disconnect callback (if applicable).
366367
"""
367368

0 commit comments

Comments
 (0)