Skip to content

Commit

Permalink
Merge pull request #1423 from aparcar/happy-pylint
Browse files Browse the repository at this point in the history
treewide: fixes to make pylint happier
  • Loading branch information
Emantor authored Jun 17, 2024
2 parents 9e0562e + bc76201 commit 41a19d4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions labgrid/driver/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def _on_message(self, client, userdata, msg):
status = True
elif msg.payload == b'OFF':
status = False
else:
raise ValueError(f"Unknown status: {msg.payload}. Must be 'ON' or 'OFF'")
self._status = status

def _on_connect(self, client, userdata, flags, reason_code, properties):
Expand Down
6 changes: 6 additions & 0 deletions labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,9 @@ def tmc_channel(self):
data = drv.get_channel_info(channel)
elif action == 'values':
data = drv.get_channel_values(channel)
else:
raise ValueError(f"unknown action {action}")

for k, v in sorted(data.items()):
print(f"{k:<16s} {str(v):<10s}")

Expand Down Expand Up @@ -1323,6 +1326,9 @@ async def export(self, place, target):
data = "\n".join(lines) + "\n"
elif self.args.format is ExportFormat.JSON:
data = json.dumps(exported)
else:
raise NotImplementedError(f"unsupported format {self.args.format}")

if self.args.filename == "-":
sys.stdout.write(data)
else:
Expand Down
12 changes: 6 additions & 6 deletions labgrid/util/agents/network_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def connection_from_dict(data):
class NMDev:
def __init__(self, interface):
self._interface = interface
self._nm_dev = nm.get_device_by_iface(interface)
self._nm_dev = nm.get_device_by_iface(interface) # pylint: disable=possibly-used-before-assignment

def _delete_connection(self, con):
future = Future()
Expand All @@ -114,7 +114,7 @@ def cb(con, res, error):
)

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

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

def configure(self, data):
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}")
lg_con = nm.get_connection_by_id(f"labgrid-{self._interface}") # pylint: disable=possibly-used-before-assignment
if lg_con:
self._delete_connection(lg_con)
data['connection'].update({
Expand All @@ -139,12 +139,12 @@ def configure(self, data):
def cb(dev, res, error):
assert error is None
try:
res = nm.add_and_activate_connection_finish(res)
res = nm.add_and_activate_connection_finish(res) # pylint: disable=possibly-used-before-assignment
future.set(res)
except Exception as e:
future.set(e)

nm.add_and_activate_connection_async(
nm.add_and_activate_connection_async( # pylint: disable=possibly-used-before-assignment
con,
self._nm_dev,
None, # specific_object
Expand Down Expand Up @@ -172,7 +172,7 @@ def wait_state(self, expected, timeout):
)

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

Expand Down
3 changes: 3 additions & 0 deletions labgrid/util/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def resolve_templates(data, mapping):
items = enumerate(data)
elif isinstance(data, dict):
items = data.items()
else:
raise TypeError(f"Expected list or dict, got {type(data)}")

for k, val in items:
if isinstance(val, Template):
try:
Expand Down

0 comments on commit 41a19d4

Please sign in to comment.