Skip to content

Commit 41a19d4

Browse files
authored
Merge pull request #1423 from aparcar/happy-pylint
treewide: fixes to make pylint happier
2 parents 9e0562e + bc76201 commit 41a19d4

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

labgrid/driver/mqtt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def _on_message(self, client, userdata, msg):
4343
status = True
4444
elif msg.payload == b'OFF':
4545
status = False
46+
else:
47+
raise ValueError(f"Unknown status: {msg.payload}. Must be 'ON' or 'OFF'")
4648
self._status = status
4749

4850
def _on_connect(self, client, userdata, flags, reason_code, properties):

labgrid/remote/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,9 @@ def tmc_channel(self):
12121212
data = drv.get_channel_info(channel)
12131213
elif action == 'values':
12141214
data = drv.get_channel_values(channel)
1215+
else:
1216+
raise ValueError(f"unknown action {action}")
1217+
12151218
for k, v in sorted(data.items()):
12161219
print(f"{k:<16s} {str(v):<10s}")
12171220

@@ -1323,6 +1326,9 @@ async def export(self, place, target):
13231326
data = "\n".join(lines) + "\n"
13241327
elif self.args.format is ExportFormat.JSON:
13251328
data = json.dumps(exported)
1329+
else:
1330+
raise NotImplementedError(f"unsupported format {self.args.format}")
1331+
13261332
if self.args.filename == "-":
13271333
sys.stdout.write(data)
13281334
else:

labgrid/util/agents/network_interface.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def connection_from_dict(data):
9595
class NMDev:
9696
def __init__(self, interface):
9797
self._interface = interface
98-
self._nm_dev = nm.get_device_by_iface(interface)
98+
self._nm_dev = nm.get_device_by_iface(interface) # pylint: disable=possibly-used-before-assignment
9999

100100
def _delete_connection(self, con):
101101
future = Future()
@@ -114,7 +114,7 @@ def cb(con, res, error):
114114
)
115115

116116
def get_settings(self):
117-
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}")
117+
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}") # pylint: disable=possibly-used-before-assignment
118118
if lg_con:
119119
return dict(lg_con.to_dbus(NM.ConnectionSerializationFlags.ALL))
120120

@@ -125,7 +125,7 @@ def get_active_settings(self):
125125
return dict(con.to_dbus(NM.ConnectionSerializationFlags.ALL))
126126

127127
def configure(self, data):
128-
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}")
128+
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}") # pylint: disable=possibly-used-before-assignment
129129
if lg_con:
130130
self._delete_connection(lg_con)
131131
data['connection'].update({
@@ -139,12 +139,12 @@ def configure(self, data):
139139
def cb(dev, res, error):
140140
assert error is None
141141
try:
142-
res = nm.add_and_activate_connection_finish(res)
142+
res = nm.add_and_activate_connection_finish(res) # pylint: disable=possibly-used-before-assignment
143143
future.set(res)
144144
except Exception as e:
145145
future.set(e)
146146

147-
nm.add_and_activate_connection_async(
147+
nm.add_and_activate_connection_async( # pylint: disable=possibly-used-before-assignment
148148
con,
149149
self._nm_dev,
150150
None, # specific_object
@@ -172,7 +172,7 @@ def wait_state(self, expected, timeout):
172172
)
173173

174174
def disable(self):
175-
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}")
175+
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}") # pylint: disable=possibly-used-before-assignment
176176
if lg_con:
177177
self._delete_connection(lg_con)
178178

labgrid/util/yaml.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def resolve_templates(data, mapping):
8484
items = enumerate(data)
8585
elif isinstance(data, dict):
8686
items = data.items()
87+
else:
88+
raise TypeError(f"Expected list or dict, got {type(data)}")
89+
8790
for k, val in items:
8891
if isinstance(val, Template):
8992
try:

0 commit comments

Comments
 (0)