Skip to content

Commit 5a79e96

Browse files
authored
Active pylint invalid-name, and solve it. (#857)
1 parent 0f265f9 commit 5a79e96

File tree

21 files changed

+133
-130
lines changed

21 files changed

+133
-130
lines changed

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ fail-on=
8181
enable=
8282
attribute-defined-outside-init,
8383
fixme,
84+
invalid-name,
8485
missing-docstring,
8586
no-self-use,
8687
protected-access,
8788
too-few-public-methods,
88-
useless-suppression
8989

9090
disable=
9191
duplicate-code,
92-
invalid-name,
9392
logging-too-many-args,
9493
use-symbolic-message-instead,
94+
useless-suppression,
9595
format # handled by black
9696

9797

examples/common/async_tornado_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def _assertor(value):
3636
# by pass assertion, an error here stops the write callbacks
3737
assert value #nosec
3838

39-
def on_done(f):
40-
if (exc := f.exception()):
39+
def on_done(f_trans):
40+
if (exc := f_trans.exception()):
4141
_logger.debug(exc)
4242
return _assertor(False)
4343

44-
return _assertor(callback(f.result()))
44+
return _assertor(callback(f_trans.result()))
4545

4646
future.add_done_callback(on_done)
4747

examples/common/async_tornado_client_serial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ def _assertor(value):
4343
# by pass assertion, an error here stops the write callbacks
4444
assert value #nosec
4545

46-
def on_done(f):
47-
if (exc := f.exception()):
46+
def on_done(f_trans):
47+
if (exc := f_trans.exception()):
4848
log.debug(exc)
4949
return _assertor(False)
5050

51-
return _assertor(callback(f.result()))
51+
return _assertor(callback(f_trans.result()))
5252

5353
future.add_done_callback(on_done)
5454

examples/contrib/message_parser.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@ def report(self, message): # pylint: disable=no-self-use
9090
:param message: The message to print
9191
"""
9292
print("%-15s = %s" % ('name', message.__class__.__name__)) #NOSONAR pylint: disable=consider-using-f-string
93-
for (k, v) in message.__dict__.items():
94-
if isinstance(v, dict):
95-
print("%-15s =" % k) # pylint: disable=consider-using-f-string
96-
for k_item, v_item in v.items():
93+
for (k_dict, v_dict) in message.__dict__.items():
94+
if isinstance(v_dict, dict):
95+
print("%-15s =" % k_dict) # pylint: disable=consider-using-f-string
96+
for k_item, v_item in v_dict.items():
9797
print(" %-12s => %s" % (k_item, v_item)) # pylint: disable=consider-using-f-string
9898

99-
elif isinstance(v, collections.Iterable): # pylint: disable=no-member
100-
print("%-15s =" % k) # pylint: disable=consider-using-f-string
101-
value = str([int(x) for x in v])
99+
elif isinstance(v_dict, collections.Iterable): # pylint: disable=no-member
100+
print("%-15s =" % k_dict) # pylint: disable=consider-using-f-string
101+
value = str([int(x) for x in v_dict])
102102
for line in textwrap.wrap(value, 60):
103103
print("%-15s . %s" % ("", line)) # pylint: disable=consider-using-f-string
104104
else:
105-
print("%-15s = %s" % (k, hex(v))) # pylint: disable=consider-using-f-string
105+
print("%-15s = %s" % (k_dict, hex(v_dict))) # pylint: disable=consider-using-f-string
106106
print("%-15s = %s" % ('documentation', message.__doc__)) # pylint: disable=consider-using-f-string
107107

108108

examples/contrib/sunspec_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,19 @@ class SunspecModel: # pylint: disable=too-few-public-methods
104104
PanelInteger = 502 # noqa E221
105105

106106
# ---------------------------------------------
107-
# 641xx Outback Blocks
107+
# 641xx outback_ Blocks
108108
# ---------------------------------------------
109-
OutbackDeviceIdentifier = 64110 # noqa E221
110-
OutbackChargeController = 64111 # noqa E221
111-
OutbackFMSeriesChargeController = 64112 # noqa E221
112-
OutbackFXInverterRealTime = 64113 # noqa E221
113-
OutbackFXInverterConfiguration = 64114 # noqa E221
114-
OutbackSplitPhaseRadianInverter = 64115 # noqa E221
115-
OutbackRadianInverterConfiguration = 64116 # noqa E221
116-
OutbackSinglePhaseRadianInverterRealTime = 64117 # noqa E221
117-
OutbackFLEXNetDCRealTime = 64118 # noqa E221
118-
OutbackFLEXNetDCConfiguration = 64119 # noqa E221
119-
OutbackSystemControl = 64120 # noqa E221
109+
outback_device_identifier = 64110 # noqa E221
110+
outback_charge_controller = 64111 # noqa E221
111+
outback_fm_charge_controller = 64112 # noqa E221
112+
outback_fx_inv_realtime = 64113 # noqa E221
113+
outback_fx_inv_conf = 64114 # noqa E221
114+
outback_split_phase_rad_inv = 64115 # noqa E221
115+
outback_radian_inv_conf = 64116 # noqa E221
116+
outback_single_phase_rad_inv_rt = 64117 # noqa E221
117+
outback_flexnet_dc_realtime = 64118 # noqa E221
118+
outback_flexnet_dc_conf = 64119 # noqa E221
119+
outback_system_control = 64120 # noqa E221
120120

121121
# ---------------------------------------------
122122
# 64xxx Vendor Extension Block

pymodbus/client/asynchronous/async_io/__init__.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,26 @@ def create_future(self): # pylint: disable=no-self-use
7575
""" Helper function to create asyncio Future object. """
7676
return asyncio.Future()
7777

78-
def resolve_future(self, f, result): # pylint: disable=no-self-use
78+
def resolve_future(self, my_future, result):
7979
""" Resolves the completed future and sets the result
8080
:param f:
8181
:param result:
8282
:return:
8383
"""
84-
if not f.done():
85-
f.set_result(result)
8684

87-
def raise_future(self, f, exc): # pylint: disable=no-self-use
85+
def resolve_future(self, my_future, result): # pylint: disable=no-self-use
86+
""" Resolve future. """
87+
if not my_future.done():
88+
my_future.set_result(result)
89+
90+
def raise_future(self, my_future, exc): # pylint: disable=no-self-use
8891
""" Sets exception of a future if not done
8992
:param f:
9093
:param exc:
9194
:return:
9295
"""
93-
if not f.done():
94-
f.set_exception(exc)
96+
if not my_future.done():
97+
my_future.set_exception(exc)
9598

9699
def _connection_made(self):
97100
""" Called upon a successful client connection. """
@@ -161,13 +164,13 @@ def _build_response(self, tid):
161164
:param tid: The transaction identifier for this response
162165
:returns: A defer linked to the latest request
163166
"""
164-
f = self.create_future()
167+
my_future = self.create_future()
165168
if not self._connected:
166-
self.raise_future(f, ConnectionException(
169+
self.raise_future(my_future, ConnectionException(
167170
'Client is not connected'))
168171
else:
169-
self.transaction.addTransaction(f, tid)
170-
return f
172+
self.transaction.addTransaction(my_future, tid)
173+
return my_future
171174

172175
def close(self):
173176
self.transport.close()

pymodbus/client/asynchronous/tornado/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ def _build_response(self, tid):
107107
:param tid:
108108
:return:
109109
"""
110-
f = Future()
110+
my_future = Future()
111111

112112
if not self._connected:
113-
f.set_exception(ConnectionException("Client is not connected"))
114-
return f
113+
my_future.set_exception(ConnectionException("Client is not connected"))
114+
return my_future
115115

116-
self.transaction.addTransaction(f, tid)
117-
return f
116+
self.transaction.addTransaction(my_future, tid)
117+
return my_future
118118

119119
def close(self):
120120
""" Closes the underlying IOStream. """
@@ -176,8 +176,8 @@ def callback(*args): # pylint: disable=unused-argument
176176
txt = f"send: {hexlify_packets(packet)}"
177177
_logger.debug(txt)
178178
self.stream.write(packet, callback=callback)
179-
f = self._build_response(request.transaction_id)
180-
return f
179+
response = self._build_response(request.transaction_id)
180+
return response
181181

182182
def _handle_response(self, reply, **kwargs): # pylint: disable=unused-argument
183183
""" Handles a received response and updates a future
@@ -198,14 +198,14 @@ def _build_response(self, tid):
198198
:param tid:
199199
:return: Future
200200
"""
201-
f = Future()
201+
my_future = Future()
202202

203203
if not self._connected:
204-
f.set_exception(ConnectionException("Client is not connected"))
205-
return f
204+
my_future.set_exception(ConnectionException("Client is not connected"))
205+
return my_future
206206

207-
self.transaction.addTransaction(f, tid)
208-
return f
207+
self.transaction.addTransaction(my_future, tid)
208+
return my_future
209209

210210
def close(self):
211211
""" Closes the underlying IOStream. """
@@ -387,7 +387,7 @@ def _on_receive(fd, events):
387387
)
388388

389389
packet = self.framer.buildPacket(request)
390-
f = self._build_response(request.transaction_id)
390+
response = self._build_response(request.transaction_id)
391391

392392
response_pdu_size = request.get_response_pdu_size()
393393
expected_response_length = self.transaction._calculate_response_length(response_pdu_size) # pylint: disable=protected-access
@@ -401,7 +401,7 @@ def _on_receive(fd, events):
401401
self.timeout_handle = self.io_loop.add_timeout(time.time() + self.timeout, _on_timeout) # pylint: disable=attribute-defined-outside-init
402402
self._send_packet(packet, callback=_on_write_done)
403403

404-
return f
404+
return response
405405

406406
def _send_packet(self, message, callback):
407407
""" Sends packets on the bus with 3.5char delay between frames

pymodbus/client/sync_diag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def __init__(self, host='127.0.0.1', port=Defaults.Port,
7979
self.warn_delay_limit = self.timeout / 2
8080

8181
# Set logging messages, defaulting to LOG_MSGS
82-
for (k, v) in LOG_MSGS.items():
83-
self.__dict__[k] = kwargs.get(k, v)
82+
for (k_item, v_item) in LOG_MSGS.items():
83+
self.__dict__[k_item] = kwargs.get(k_item, v_item)
8484

8585
def connect(self):
8686
""" Connect to the modbus tcp server

pymodbus/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class ModbusStatus(Singleton): # pylint: disable=too-few-public-methods
163163
"""
164164
Waiting = 0xffff
165165
Ready = 0x0000
166-
On = 0xff00
166+
On = 0xff00 # pylint: disable=invalid-name
167167
Off = 0x0000
168168
SlaveOn = 0xff
169169
SlaveOff = 0x00

pymodbus/datastore/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ def _process_values(self, values):
266266
def _process_as_dict(values):
267267
for idx, val in iter(values.items()):
268268
if isinstance(val, (list, tuple)):
269-
for i, v in enumerate(val):
270-
self.values[idx + i] = v
269+
for i, v_item in enumerate(val):
270+
self.values[idx + i] = v_item
271271
else:
272272
self.values[idx] = int(val)
273273
if isinstance(values, dict):

0 commit comments

Comments
 (0)