Merge ~smoser/cloud-init:cleanup/pylint-respect-W0612-unused-variable into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: 3ddd3a322945a9bff8d1906fe2a268c70f851b92
Merge reported by: Chad Smith
Merged at revision: 1081962eacf2814fea6f4fa3255c530de14e4a24
Proposed branch: ~smoser/cloud-init:cleanup/pylint-respect-W0612-unused-variable
Merge into: cloud-init:master
Diff against target: 955 lines (+95/-112)
51 files modified
.pylintrc (+1/-1)
cloudinit/analyze/dump.py (+1/-1)
cloudinit/cmd/tests/test_main.py (+3/-3)
cloudinit/config/cc_apt_configure.py (+1/-1)
cloudinit/config/cc_emit_upstart.py (+1/-1)
cloudinit/config/cc_resizefs.py (+3/-5)
cloudinit/config/cc_rh_subscription.py (+8/-10)
cloudinit/config/cc_snap.py (+2/-2)
cloudinit/config/cc_snappy.py (+2/-2)
cloudinit/config/cc_ubuntu_advantage.py (+2/-2)
cloudinit/config/schema.py (+2/-2)
cloudinit/distros/freebsd.py (+1/-1)
cloudinit/distros/ubuntu.py (+1/-1)
cloudinit/net/__init__.py (+1/-1)
cloudinit/net/cmdline.py (+1/-1)
cloudinit/net/dhcp.py (+1/-1)
cloudinit/net/sysconfig.py (+1/-1)
cloudinit/reporting/events.py (+1/-1)
cloudinit/sources/DataSourceAliYun.py (+1/-1)
cloudinit/sources/DataSourceAzure.py (+13/-20)
cloudinit/sources/DataSourceMAAS.py (+1/-1)
cloudinit/sources/DataSourceOVF.py (+1/-1)
cloudinit/sources/DataSourceOpenStack.py (+2/-2)
cloudinit/sources/helpers/digitalocean.py (+3/-4)
cloudinit/sources/helpers/openstack.py (+1/-1)
cloudinit/sources/helpers/vmware/imc/config_nic.py (+1/-1)
cloudinit/sources/helpers/vmware/imc/config_passwd.py (+2/-2)
cloudinit/sources/helpers/vmware/imc/guestcust_util.py (+2/-2)
cloudinit/sources/tests/test_init.py (+1/-1)
cloudinit/templater.py (+1/-1)
cloudinit/tests/helpers.py (+1/-1)
cloudinit/tests/test_util.py (+1/-1)
cloudinit/url_helper.py (+1/-1)
cloudinit/util.py (+1/-1)
tests/cloud_tests/bddeb.py (+1/-1)
tests/cloud_tests/collect.py (+2/-1)
tests/cloud_tests/platforms/instances.py (+1/-1)
tests/cloud_tests/platforms/lxd/instance.py (+4/-6)
tests/cloud_tests/setup_image.py (+5/-6)
tests/cloud_tests/testcases/base.py (+1/-1)
tests/cloud_tests/testcases/examples/including_user_groups.py (+1/-1)
tests/cloud_tests/testcases/modules/user_groups.py (+1/-1)
tests/cloud_tests/util.py (+1/-1)
tests/unittests/test__init__.py (+1/-1)
tests/unittests/test_datasource/test_azure.py (+2/-2)
tests/unittests/test_datasource/test_maas.py (+2/-2)
tests/unittests/test_datasource/test_nocloud.py (+0/-3)
tests/unittests/test_handler/test_handler_apt_source_v3.py (+1/-1)
tests/unittests/test_handler/test_handler_ntp.py (+1/-1)
tests/unittests/test_templating.py (+2/-2)
tests/unittests/test_util.py (+3/-3)
Reviewer Review Type Date Requested Status
Ryan Harper Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+343469@code.launchpad.net

Commit message

pylint: pay attention to unused variable warnings.

This enables warnings produced by pylint for unused variables (W0612),
and fixes the existing errors.

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:2a46897cce9284be00a722d7b2b30a8a8f28a6e9
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1019/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1019/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Fix your commit message, you're paying attention to:

# W0612(unused-variable)

Not

# W0621(redefined-outer-name)

Revision history for this message
Ryan Harper (raharper) wrote :

tox -e pylint finds a few more for me.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:41e3e47422f4c4bbb4fcbbd93ebf5b03b56f979d
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1020/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1020/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:3ddd3a322945a9bff8d1906fe2a268c70f851b92
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1021/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1021/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Looks good.

review: Approve
Revision history for this message
Chad Smith (chad.smith) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=1081962e

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.pylintrc b/.pylintrc
2index 0bdfa59..3bfa0c8 100644
3--- a/.pylintrc
4+++ b/.pylintrc
5@@ -28,7 +28,7 @@ jobs=4
6 # W0703(broad-except)
7 # W1401(anomalous-backslash-in-string)
8
9-disable=C, F, I, R, W0105, W0107, W0201, W0212, W0221, W0222, W0223, W0231, W0311, W0511, W0602, W0603, W0611, W0612, W0613, W0621, W0622, W0631, W0703, W1401
10+disable=C, F, I, R, W0105, W0107, W0201, W0212, W0221, W0222, W0223, W0231, W0311, W0511, W0602, W0603, W0611, W0613, W0621, W0622, W0631, W0703, W1401
11
12
13 [REPORTS]
14diff --git a/cloudinit/analyze/dump.py b/cloudinit/analyze/dump.py
15index b071aa1..1f3060d 100644
16--- a/cloudinit/analyze/dump.py
17+++ b/cloudinit/analyze/dump.py
18@@ -112,7 +112,7 @@ def parse_ci_logline(line):
19 return None
20 event_description = stage_to_description[event_name]
21 else:
22- (pymodloglvl, event_type, event_name) = eventstr.split()[0:3]
23+ (_pymodloglvl, event_type, event_name) = eventstr.split()[0:3]
24 event_description = eventstr.split(event_name)[1].strip()
25
26 event = {
27diff --git a/cloudinit/cmd/tests/test_main.py b/cloudinit/cmd/tests/test_main.py
28index dbe421c..e2c54ae 100644
29--- a/cloudinit/cmd/tests/test_main.py
30+++ b/cloudinit/cmd/tests/test_main.py
31@@ -56,7 +56,7 @@ class TestMain(FilesystemMockingTestCase):
32 cmdargs = myargs(
33 debug=False, files=None, force=False, local=False, reporter=None,
34 subcommand='init')
35- (item1, item2) = wrap_and_call(
36+ (_item1, item2) = wrap_and_call(
37 'cloudinit.cmd.main',
38 {'util.close_stdin': True,
39 'netinfo.debug_info': 'my net debug info',
40@@ -85,7 +85,7 @@ class TestMain(FilesystemMockingTestCase):
41 cmdargs = myargs(
42 debug=False, files=None, force=False, local=False, reporter=None,
43 subcommand='init')
44- (item1, item2) = wrap_and_call(
45+ (_item1, item2) = wrap_and_call(
46 'cloudinit.cmd.main',
47 {'util.close_stdin': True,
48 'netinfo.debug_info': 'my net debug info',
49@@ -133,7 +133,7 @@ class TestMain(FilesystemMockingTestCase):
50 self.assertEqual(main.LOG, log)
51 self.assertIsNone(args)
52
53- (item1, item2) = wrap_and_call(
54+ (_item1, item2) = wrap_and_call(
55 'cloudinit.cmd.main',
56 {'util.close_stdin': True,
57 'netinfo.debug_info': 'my net debug info',
58diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
59index 5b9cbca..e4cc993 100644
60--- a/cloudinit/config/cc_apt_configure.py
61+++ b/cloudinit/config/cc_apt_configure.py
62@@ -378,7 +378,7 @@ def apply_debconf_selections(cfg, target=None):
63
64 # get a complete list of packages listed in input
65 pkgs_cfgd = set()
66- for key, content in selsets.items():
67+ for _key, content in selsets.items():
68 for line in content.splitlines():
69 if line.startswith("#"):
70 continue
71diff --git a/cloudinit/config/cc_emit_upstart.py b/cloudinit/config/cc_emit_upstart.py
72index 69dc2d5..eb9fbe6 100644
73--- a/cloudinit/config/cc_emit_upstart.py
74+++ b/cloudinit/config/cc_emit_upstart.py
75@@ -43,7 +43,7 @@ def is_upstart_system():
76 del myenv['UPSTART_SESSION']
77 check_cmd = ['initctl', 'version']
78 try:
79- (out, err) = util.subp(check_cmd, env=myenv)
80+ (out, _err) = util.subp(check_cmd, env=myenv)
81 return 'upstart' in out
82 except util.ProcessExecutionError as e:
83 LOG.debug("'%s' returned '%s', not using upstart",
84diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
85index 013e69b..82f29e1 100644
86--- a/cloudinit/config/cc_resizefs.py
87+++ b/cloudinit/config/cc_resizefs.py
88@@ -89,13 +89,11 @@ def _resize_zfs(mount_point, devpth):
89
90
91 def _get_dumpfs_output(mount_point):
92- dumpfs_res, err = util.subp(['dumpfs', '-m', mount_point])
93- return dumpfs_res
94+ return util.subp(['dumpfs', '-m', mount_point])[0]
95
96
97 def _get_gpart_output(part):
98- gpart_res, err = util.subp(['gpart', 'show', part])
99- return gpart_res
100+ return util.subp(['gpart', 'show', part])[0]
101
102
103 def _can_skip_resize_ufs(mount_point, devpth):
104@@ -113,7 +111,7 @@ def _can_skip_resize_ufs(mount_point, devpth):
105 if not line.startswith('#'):
106 newfs_cmd = shlex.split(line)
107 opt_value = 'O:Ua:s:b:d:e:f:g:h:i:jk:m:o:'
108- optlist, args = getopt.getopt(newfs_cmd[1:], opt_value)
109+ optlist, _args = getopt.getopt(newfs_cmd[1:], opt_value)
110 for o, a in optlist:
111 if o == "-s":
112 cur_fs_sz = int(a)
113diff --git a/cloudinit/config/cc_rh_subscription.py b/cloudinit/config/cc_rh_subscription.py
114index 530808c..1c67943 100644
115--- a/cloudinit/config/cc_rh_subscription.py
116+++ b/cloudinit/config/cc_rh_subscription.py
117@@ -209,8 +209,7 @@ class SubscriptionManager(object):
118 cmd.append("--serverurl={0}".format(self.server_hostname))
119
120 try:
121- return_out, return_err = self._sub_man_cli(cmd,
122- logstring_val=True)
123+ return_out = self._sub_man_cli(cmd, logstring_val=True)[0]
124 except util.ProcessExecutionError as e:
125 if e.stdout == "":
126 self.log_warn("Registration failed due "
127@@ -233,8 +232,7 @@ class SubscriptionManager(object):
128
129 # Attempting to register the system only
130 try:
131- return_out, return_err = self._sub_man_cli(cmd,
132- logstring_val=True)
133+ return_out = self._sub_man_cli(cmd, logstring_val=True)[0]
134 except util.ProcessExecutionError as e:
135 if e.stdout == "":
136 self.log_warn("Registration failed due "
137@@ -257,7 +255,7 @@ class SubscriptionManager(object):
138 .format(self.servicelevel)]
139
140 try:
141- return_out, return_err = self._sub_man_cli(cmd)
142+ return_out = self._sub_man_cli(cmd)[0]
143 except util.ProcessExecutionError as e:
144 if e.stdout.rstrip() != '':
145 for line in e.stdout.split("\n"):
146@@ -275,7 +273,7 @@ class SubscriptionManager(object):
147 def _set_auto_attach(self):
148 cmd = ['attach', '--auto']
149 try:
150- return_out, return_err = self._sub_man_cli(cmd)
151+ return_out = self._sub_man_cli(cmd)[0]
152 except util.ProcessExecutionError as e:
153 self.log_warn("Auto-attach failed with: {0}".format(e))
154 return False
155@@ -294,12 +292,12 @@ class SubscriptionManager(object):
156
157 # Get all available pools
158 cmd = ['list', '--available', '--pool-only']
159- results, errors = self._sub_man_cli(cmd)
160+ results = self._sub_man_cli(cmd)[0]
161 available = (results.rstrip()).split("\n")
162
163 # Get all consumed pools
164 cmd = ['list', '--consumed', '--pool-only']
165- results, errors = self._sub_man_cli(cmd)
166+ results = self._sub_man_cli(cmd)[0]
167 consumed = (results.rstrip()).split("\n")
168
169 return available, consumed
170@@ -311,14 +309,14 @@ class SubscriptionManager(object):
171 '''
172
173 cmd = ['repos', '--list-enabled']
174- return_out, return_err = self._sub_man_cli(cmd)
175+ return_out = self._sub_man_cli(cmd)[0]
176 active_repos = []
177 for repo in return_out.split("\n"):
178 if "Repo ID:" in repo:
179 active_repos.append((repo.split(':')[1]).strip())
180
181 cmd = ['repos', '--list-disabled']
182- return_out, return_err = self._sub_man_cli(cmd)
183+ return_out = self._sub_man_cli(cmd)[0]
184
185 inactive_repos = []
186 for repo in return_out.split("\n"):
187diff --git a/cloudinit/config/cc_snap.py b/cloudinit/config/cc_snap.py
188index 34a53fd..202044c 100644
189--- a/cloudinit/config/cc_snap.py
190+++ b/cloudinit/config/cc_snap.py
191@@ -204,12 +204,12 @@ def maybe_install_squashfuse(cloud):
192 return
193 try:
194 cloud.distro.update_package_sources()
195- except Exception as e:
196+ except Exception:
197 util.logexc(LOG, "Package update failed")
198 raise
199 try:
200 cloud.distro.install_packages(['squashfuse'])
201- except Exception as e:
202+ except Exception:
203 util.logexc(LOG, "Failed to install squashfuse")
204 raise
205
206diff --git a/cloudinit/config/cc_snappy.py b/cloudinit/config/cc_snappy.py
207index bab80bb..15bee2d 100644
208--- a/cloudinit/config/cc_snappy.py
209+++ b/cloudinit/config/cc_snappy.py
210@@ -213,7 +213,7 @@ def render_snap_op(op, name, path=None, cfgfile=None, config=None):
211
212 def read_installed_packages():
213 ret = []
214- for (name, date, version, dev) in read_pkg_data():
215+ for (name, _date, _version, dev) in read_pkg_data():
216 if dev:
217 ret.append(NAMESPACE_DELIM.join([name, dev]))
218 else:
219@@ -222,7 +222,7 @@ def read_installed_packages():
220
221
222 def read_pkg_data():
223- out, err = util.subp([SNAPPY_CMD, "list"])
224+ out, _err = util.subp([SNAPPY_CMD, "list"])
225 pkg_data = []
226 for line in out.splitlines()[1:]:
227 toks = line.split(sep=None, maxsplit=3)
228diff --git a/cloudinit/config/cc_ubuntu_advantage.py b/cloudinit/config/cc_ubuntu_advantage.py
229index 16b1868..903704f 100644
230--- a/cloudinit/config/cc_ubuntu_advantage.py
231+++ b/cloudinit/config/cc_ubuntu_advantage.py
232@@ -149,12 +149,12 @@ def maybe_install_ua_tools(cloud):
233 return
234 try:
235 cloud.distro.update_package_sources()
236- except Exception as e:
237+ except Exception:
238 util.logexc(LOG, "Package update failed")
239 raise
240 try:
241 cloud.distro.install_packages(['ubuntu-advantage-tools'])
242- except Exception as e:
243+ except Exception:
244 util.logexc(LOG, "Failed to install ubuntu-advantage-tools")
245 raise
246
247diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py
248index ca7d0d5..76826e0 100644
249--- a/cloudinit/config/schema.py
250+++ b/cloudinit/config/schema.py
251@@ -297,8 +297,8 @@ def get_schema():
252
253 configs_dir = os.path.dirname(os.path.abspath(__file__))
254 potential_handlers = find_modules(configs_dir)
255- for (fname, mod_name) in potential_handlers.items():
256- mod_locs, looked_locs = importer.find_module(
257+ for (_fname, mod_name) in potential_handlers.items():
258+ mod_locs, _looked_locs = importer.find_module(
259 mod_name, ['cloudinit.config'], ['schema'])
260 if mod_locs:
261 mod = importer.import_module(mod_locs[0])
262diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py
263index 754d3df..03ee091 100644
264--- a/cloudinit/distros/freebsd.py
265+++ b/cloudinit/distros/freebsd.py
266@@ -113,7 +113,7 @@ class Distro(distros.Distro):
267 n = re.search('\d+$', dev)
268 index = n.group(0)
269
270- (out, err) = util.subp(['ifconfig', '-a'])
271+ (out, _err) = util.subp(['ifconfig', '-a'])
272 ifconfigoutput = [x for x in (out.strip()).splitlines()
273 if len(x.split()) > 0]
274 bsddev = 'NOT_FOUND'
275diff --git a/cloudinit/distros/ubuntu.py b/cloudinit/distros/ubuntu.py
276index fdc1f62..6815410 100644
277--- a/cloudinit/distros/ubuntu.py
278+++ b/cloudinit/distros/ubuntu.py
279@@ -25,7 +25,7 @@ class Distro(debian.Distro):
280 def preferred_ntp_clients(self):
281 """The preferred ntp client is dependent on the version."""
282 if not self._preferred_ntp_clients:
283- (name, version, codename) = util.system_info()['dist']
284+ (_name, _version, codename) = util.system_info()['dist']
285 # Xenial cloud-init only installed ntp, UbuntuCore has timesyncd.
286 if codename == "xenial" and not util.system_is_snappy():
287 self._preferred_ntp_clients = ['ntp']
288diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
289index f69c0ef..8005454 100644
290--- a/cloudinit/net/__init__.py
291+++ b/cloudinit/net/__init__.py
292@@ -295,7 +295,7 @@ def apply_network_config_names(netcfg, strict_present=True, strict_busy=True):
293
294 def _version_2(netcfg):
295 renames = []
296- for key, ent in netcfg.get('ethernets', {}).items():
297+ for ent in netcfg.get('ethernets', {}).values():
298 # only rename if configured to do so
299 name = ent.get('set-name')
300 if not name:
301diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
302index 9e9fe0f..f89a0f7 100755
303--- a/cloudinit/net/cmdline.py
304+++ b/cloudinit/net/cmdline.py
305@@ -65,7 +65,7 @@ def _klibc_to_config_entry(content, mac_addrs=None):
306 iface['mac_address'] = mac_addrs[name]
307
308 # Handle both IPv4 and IPv6 values
309- for v, pre in (('ipv4', 'IPV4'), ('ipv6', 'IPV6')):
310+ for pre in ('IPV4', 'IPV6'):
311 # if no IPV4ADDR or IPV6ADDR, then go on.
312 if pre + "ADDR" not in data:
313 continue
314diff --git a/cloudinit/net/dhcp.py b/cloudinit/net/dhcp.py
315index 087c0c0..12cf509 100644
316--- a/cloudinit/net/dhcp.py
317+++ b/cloudinit/net/dhcp.py
318@@ -216,7 +216,7 @@ def networkd_get_option_from_leases(keyname, leases_d=None):
319 if leases_d is None:
320 leases_d = NETWORKD_LEASES_DIR
321 leases = networkd_load_leases(leases_d=leases_d)
322- for ifindex, data in sorted(leases.items()):
323+ for _ifindex, data in sorted(leases.items()):
324 if data.get(keyname):
325 return data[keyname]
326 return None
327diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
328index 39d89c4..7a7f509 100644
329--- a/cloudinit/net/sysconfig.py
330+++ b/cloudinit/net/sysconfig.py
331@@ -364,7 +364,7 @@ class Renderer(renderer.Renderer):
332
333 @classmethod
334 def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
335- for i, subnet in enumerate(subnets, start=len(iface_cfg.children)):
336+ for _, subnet in enumerate(subnets, start=len(iface_cfg.children)):
337 for route in subnet.get('routes', []):
338 is_ipv6 = subnet.get('ipv6') or is_ipv6_addr(route['gateway'])
339
340diff --git a/cloudinit/reporting/events.py b/cloudinit/reporting/events.py
341index 4f62d2f..e5dfab3 100644
342--- a/cloudinit/reporting/events.py
343+++ b/cloudinit/reporting/events.py
344@@ -192,7 +192,7 @@ class ReportEventStack(object):
345
346 def _childrens_finish_info(self):
347 for cand_result in (status.FAIL, status.WARN):
348- for name, (value, msg) in self.children.items():
349+ for _name, (value, _msg) in self.children.items():
350 if value == cand_result:
351 return (value, self.message)
352 return (self.result, self.message)
353diff --git a/cloudinit/sources/DataSourceAliYun.py b/cloudinit/sources/DataSourceAliYun.py
354index 22279d0..858e082 100644
355--- a/cloudinit/sources/DataSourceAliYun.py
356+++ b/cloudinit/sources/DataSourceAliYun.py
357@@ -45,7 +45,7 @@ def _is_aliyun():
358
359 def parse_public_keys(public_keys):
360 keys = []
361- for key_id, key_body in public_keys.items():
362+ for _key_id, key_body in public_keys.items():
363 if isinstance(key_body, str):
364 keys.append(key_body.strip())
365 elif isinstance(key_body, list):
366diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
367index 0ee622e..a71197a 100644
368--- a/cloudinit/sources/DataSourceAzure.py
369+++ b/cloudinit/sources/DataSourceAzure.py
370@@ -107,31 +107,24 @@ def find_dev_from_busdev(camcontrol_out, busdev):
371 return None
372
373
374-def get_dev_storvsc_sysctl():
375+def execute_or_debug(cmd, fail_ret=None):
376 try:
377- sysctl_out, err = util.subp(['sysctl', 'dev.storvsc'])
378+ return util.subp(cmd)[0]
379 except util.ProcessExecutionError:
380- LOG.debug("Fail to execute sysctl dev.storvsc")
381- sysctl_out = ""
382- return sysctl_out
383+ LOG.debug("Failed to execute: %s", ' '.join(cmd))
384+ return fail_ret
385+
386+
387+def get_dev_storvsc_sysctl():
388+ return execute_or_debug(["sysctl", "dev.storvsc"], fail_ret="")
389
390
391 def get_camcontrol_dev_bus():
392- try:
393- camcontrol_b_out, err = util.subp(['camcontrol', 'devlist', '-b'])
394- except util.ProcessExecutionError:
395- LOG.debug("Fail to execute camcontrol devlist -b")
396- return None
397- return camcontrol_b_out
398+ return execute_or_debug(['camcontrol', 'devlist', '-b'])
399
400
401 def get_camcontrol_dev():
402- try:
403- camcontrol_out, err = util.subp(['camcontrol', 'devlist'])
404- except util.ProcessExecutionError:
405- LOG.debug("Fail to execute camcontrol devlist")
406- return None
407- return camcontrol_out
408+ return execute_or_debug(['camcontrol', 'devlist'])
409
410
411 def get_resource_disk_on_freebsd(port_id):
412@@ -474,7 +467,7 @@ class DataSourceAzure(sources.DataSource):
413 before we go into our polling loop."""
414 try:
415 get_metadata_from_fabric(None, lease['unknown-245'])
416- except Exception as exc:
417+ except Exception:
418 LOG.warning(
419 "Error communicating with Azure fabric; You may experience."
420 "connectivity issues.", exc_info=True)
421@@ -492,7 +485,7 @@ class DataSourceAzure(sources.DataSource):
422 jump back into the polling loop in order to retrieve the ovf_env."""
423 if not ret:
424 return False
425- (md, self.userdata_raw, cfg, files) = ret
426+ (_md, self.userdata_raw, cfg, _files) = ret
427 path = REPROVISION_MARKER_FILE
428 if (cfg.get('PreprovisionedVm') is True or
429 os.path.isfile(path)):
430@@ -528,7 +521,7 @@ class DataSourceAzure(sources.DataSource):
431 self.ds_cfg['agent_command'])
432 try:
433 fabric_data = metadata_func()
434- except Exception as exc:
435+ except Exception:
436 LOG.warning(
437 "Error communicating with Azure fabric; You may experience."
438 "connectivity issues.", exc_info=True)
439diff --git a/cloudinit/sources/DataSourceMAAS.py b/cloudinit/sources/DataSourceMAAS.py
440index 6ac8863..aa56add 100644
441--- a/cloudinit/sources/DataSourceMAAS.py
442+++ b/cloudinit/sources/DataSourceMAAS.py
443@@ -204,7 +204,7 @@ def read_maas_seed_url(seed_url, read_file_or_url=None, timeout=None,
444 seed_url = seed_url[:-1]
445
446 md = {}
447- for path, dictname, binary, optional in DS_FIELDS:
448+ for path, _dictname, binary, optional in DS_FIELDS:
449 if version is None:
450 url = "%s/%s" % (seed_url, path)
451 else:
452diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py
453index dc914a7..178ccb0 100644
454--- a/cloudinit/sources/DataSourceOVF.py
455+++ b/cloudinit/sources/DataSourceOVF.py
456@@ -556,7 +556,7 @@ def search_file(dirpath, filename):
457 if not dirpath or not filename:
458 return None
459
460- for root, dirs, files in os.walk(dirpath):
461+ for root, _dirs, files in os.walk(dirpath):
462 if filename in files:
463 return os.path.join(root, filename)
464
465diff --git a/cloudinit/sources/DataSourceOpenStack.py b/cloudinit/sources/DataSourceOpenStack.py
466index e55a763..fb166ae 100644
467--- a/cloudinit/sources/DataSourceOpenStack.py
468+++ b/cloudinit/sources/DataSourceOpenStack.py
469@@ -86,7 +86,7 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
470 md_urls.append(md_url)
471 url2base[md_url] = url
472
473- (max_wait, timeout, retries) = self._get_url_settings()
474+ (max_wait, timeout, _retries) = self._get_url_settings()
475 start_time = time.time()
476 avail_url = url_helper.wait_for_url(urls=md_urls, max_wait=max_wait,
477 timeout=timeout)
478@@ -106,7 +106,7 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
479 except IOError:
480 return False
481
482- (max_wait, timeout, retries) = self._get_url_settings()
483+ (_max_wait, timeout, retries) = self._get_url_settings()
484
485 try:
486 results = util.log_time(LOG.debug,
487diff --git a/cloudinit/sources/helpers/digitalocean.py b/cloudinit/sources/helpers/digitalocean.py
488index 693f8d5..0e7ccca 100644
489--- a/cloudinit/sources/helpers/digitalocean.py
490+++ b/cloudinit/sources/helpers/digitalocean.py
491@@ -41,10 +41,9 @@ def assign_ipv4_link_local(nic=None):
492 "address")
493
494 try:
495- (result, _err) = util.subp(ip_addr_cmd)
496+ util.subp(ip_addr_cmd)
497 LOG.debug("assigned ip4LL address '%s' to '%s'", addr, nic)
498-
499- (result, _err) = util.subp(ip_link_cmd)
500+ util.subp(ip_link_cmd)
501 LOG.debug("brought device '%s' up", nic)
502 except Exception:
503 util.logexc(LOG, "ip4LL address assignment of '%s' to '%s' failed."
504@@ -75,7 +74,7 @@ def del_ipv4_link_local(nic=None):
505 ip_addr_cmd = ['ip', 'addr', 'flush', 'dev', nic]
506
507 try:
508- (result, _err) = util.subp(ip_addr_cmd)
509+ util.subp(ip_addr_cmd)
510 LOG.debug("removed ip4LL addresses from %s", nic)
511
512 except Exception as e:
513diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
514index 26f3168..a4cf066 100644
515--- a/cloudinit/sources/helpers/openstack.py
516+++ b/cloudinit/sources/helpers/openstack.py
517@@ -638,7 +638,7 @@ def convert_net_json(network_json=None, known_macs=None):
518 known_macs = net.get_interfaces_by_mac()
519
520 # go through and fill out the link_id_info with names
521- for link_id, info in link_id_info.items():
522+ for _link_id, info in link_id_info.items():
523 if info.get('name'):
524 continue
525 if info.get('mac') in known_macs:
526diff --git a/cloudinit/sources/helpers/vmware/imc/config_nic.py b/cloudinit/sources/helpers/vmware/imc/config_nic.py
527index 2d8900e..3ef8c62 100644
528--- a/cloudinit/sources/helpers/vmware/imc/config_nic.py
529+++ b/cloudinit/sources/helpers/vmware/imc/config_nic.py
530@@ -73,7 +73,7 @@ class NicConfigurator(object):
531 The mac address(es) are in the lower case
532 """
533 cmd = ['ip', 'addr', 'show']
534- (output, err) = util.subp(cmd)
535+ output, _err = util.subp(cmd)
536 sections = re.split(r'\n\d+: ', '\n' + output)[1:]
537
538 macPat = r'link/ether (([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2}))'
539diff --git a/cloudinit/sources/helpers/vmware/imc/config_passwd.py b/cloudinit/sources/helpers/vmware/imc/config_passwd.py
540index 75cfbaa..8c91fa4 100644
541--- a/cloudinit/sources/helpers/vmware/imc/config_passwd.py
542+++ b/cloudinit/sources/helpers/vmware/imc/config_passwd.py
543@@ -56,10 +56,10 @@ class PasswordConfigurator(object):
544 LOG.info('Expiring password.')
545 for user in uidUserList:
546 try:
547- out, err = util.subp(['passwd', '--expire', user])
548+ util.subp(['passwd', '--expire', user])
549 except util.ProcessExecutionError as e:
550 if os.path.exists('/usr/bin/chage'):
551- out, e = util.subp(['chage', '-d', '0', user])
552+ util.subp(['chage', '-d', '0', user])
553 else:
554 LOG.warning('Failed to expire password for %s with error: '
555 '%s', user, e)
556diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
557index 4407525..a590f32 100644
558--- a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
559+++ b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
560@@ -91,7 +91,7 @@ def enable_nics(nics):
561
562 for attempt in range(0, enableNicsWaitRetries):
563 logger.debug("Trying to connect interfaces, attempt %d", attempt)
564- (out, err) = set_customization_status(
565+ (out, _err) = set_customization_status(
566 GuestCustStateEnum.GUESTCUST_STATE_RUNNING,
567 GuestCustEventEnum.GUESTCUST_EVENT_ENABLE_NICS,
568 nics)
569@@ -104,7 +104,7 @@ def enable_nics(nics):
570 return
571
572 for count in range(0, enableNicsWaitCount):
573- (out, err) = set_customization_status(
574+ (out, _err) = set_customization_status(
575 GuestCustStateEnum.GUESTCUST_STATE_RUNNING,
576 GuestCustEventEnum.GUESTCUST_EVENT_QUERY_NICS,
577 nics)
578diff --git a/cloudinit/sources/tests/test_init.py b/cloudinit/sources/tests/test_init.py
579index e7fda22..452e921 100644
580--- a/cloudinit/sources/tests/test_init.py
581+++ b/cloudinit/sources/tests/test_init.py
582@@ -278,7 +278,7 @@ class TestDataSource(CiTestCase):
583 base_args = get_args(DataSource.get_hostname) # pylint: disable=W1505
584 # Import all DataSource subclasses so we can inspect them.
585 modules = util.find_modules(os.path.dirname(os.path.dirname(__file__)))
586- for loc, name in modules.items():
587+ for _loc, name in modules.items():
588 mod_locs, _ = importer.find_module(name, ['cloudinit.sources'], [])
589 if mod_locs:
590 importer.import_module(mod_locs[0])
591diff --git a/cloudinit/templater.py b/cloudinit/templater.py
592index 9a087e1..7e7acb8 100644
593--- a/cloudinit/templater.py
594+++ b/cloudinit/templater.py
595@@ -147,7 +147,7 @@ def render_string(content, params):
596 Warning: py2 str with non-ascii chars will cause UnicodeDecodeError."""
597 if not params:
598 params = {}
599- template_type, renderer, content = detect_template(content)
600+ _template_type, renderer, content = detect_template(content)
601 return renderer(content, params)
602
603 # vi: ts=4 expandtab
604diff --git a/cloudinit/tests/helpers.py b/cloudinit/tests/helpers.py
605index 999b1d7..996888e 100644
606--- a/cloudinit/tests/helpers.py
607+++ b/cloudinit/tests/helpers.py
608@@ -358,7 +358,7 @@ def dir2dict(startdir, prefix=None):
609 flist = {}
610 if prefix is None:
611 prefix = startdir
612- for root, dirs, files in os.walk(startdir):
613+ for root, _dirs, files in os.walk(startdir):
614 for fname in files:
615 fpath = os.path.join(root, fname)
616 key = fpath[len(prefix):]
617diff --git a/cloudinit/tests/test_util.py b/cloudinit/tests/test_util.py
618index 3f37dbb..76eed07 100644
619--- a/cloudinit/tests/test_util.py
620+++ b/cloudinit/tests/test_util.py
621@@ -135,7 +135,7 @@ class TestGetHostnameFqdn(CiTestCase):
622 def test_get_hostname_fqdn_from_passes_metadata_only_to_cloud(self):
623 """Calls to cloud.get_hostname pass the metadata_only parameter."""
624 mycloud = FakeCloud('cloudhost', 'cloudhost.mycloud.com')
625- hostname, fqdn = util.get_hostname_fqdn(
626+ _hn, _fqdn = util.get_hostname_fqdn(
627 cfg={}, cloud=mycloud, metadata_only=True)
628 self.assertEqual(
629 [{'fqdn': True, 'metadata_only': True},
630diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py
631index 03a573a..1de07b1 100644
632--- a/cloudinit/url_helper.py
633+++ b/cloudinit/url_helper.py
634@@ -519,7 +519,7 @@ def oauth_headers(url, consumer_key, token_key, token_secret, consumer_secret,
635 resource_owner_secret=token_secret,
636 signature_method=oauth1.SIGNATURE_PLAINTEXT,
637 timestamp=timestamp)
638- uri, signed_headers, body = client.sign(url)
639+ _uri, signed_headers, _body = client.sign(url)
640 return signed_headers
641
642 # vi: ts=4 expandtab
643diff --git a/cloudinit/util.py b/cloudinit/util.py
644index acdc0d8..d8b5e09 100644
645--- a/cloudinit/util.py
646+++ b/cloudinit/util.py
647@@ -2214,7 +2214,7 @@ def parse_mtab(path):
648 def find_freebsd_part(label_part):
649 if label_part.startswith("/dev/label/"):
650 target_label = label_part[5:]
651- (label_part, err) = subp(['glabel', 'status', '-s'])
652+ (label_part, _err) = subp(['glabel', 'status', '-s'])
653 for labels in label_part.split("\n"):
654 items = labels.split()
655 if len(items) > 0 and items[0].startswith(target_label):
656diff --git a/tests/cloud_tests/bddeb.py b/tests/cloud_tests/bddeb.py
657index b9cfcfa..f04d0cd 100644
658--- a/tests/cloud_tests/bddeb.py
659+++ b/tests/cloud_tests/bddeb.py
660@@ -113,7 +113,7 @@ def bddeb(args):
661 @return_value: fail count
662 """
663 LOG.info('preparing to build cloud-init deb')
664- (res, failed) = run_stage('build deb', [partial(setup_build, args)])
665+ _res, failed = run_stage('build deb', [partial(setup_build, args)])
666 return failed
667
668 # vi: ts=4 expandtab
669diff --git a/tests/cloud_tests/collect.py b/tests/cloud_tests/collect.py
670index d4f9135..1ba7285 100644
671--- a/tests/cloud_tests/collect.py
672+++ b/tests/cloud_tests/collect.py
673@@ -25,7 +25,8 @@ def collect_script(instance, base_dir, script, script_name):
674 script.encode(), rcs=False,
675 description='collect: {}'.format(script_name))
676 if err:
677- LOG.debug("collect script %s had stderr: %s", script_name, err)
678+ LOG.debug("collect script %s exited '%s' and had stderr: %s",
679+ script_name, err, exit)
680 if not isinstance(out, bytes):
681 raise util.PlatformError(
682 "Collection of '%s' returned type %s, expected bytes: %s" %
683diff --git a/tests/cloud_tests/platforms/instances.py b/tests/cloud_tests/platforms/instances.py
684index 3bad021..cc439d2 100644
685--- a/tests/cloud_tests/platforms/instances.py
686+++ b/tests/cloud_tests/platforms/instances.py
687@@ -108,7 +108,7 @@ class Instance(TargetBase):
688 return client
689 except (ConnectionRefusedError, AuthenticationException,
690 BadHostKeyException, ConnectionResetError, SSHException,
691- OSError) as e:
692+ OSError):
693 retries -= 1
694 time.sleep(10)
695
696diff --git a/tests/cloud_tests/platforms/lxd/instance.py b/tests/cloud_tests/platforms/lxd/instance.py
697index 0d957bc..1c17c78 100644
698--- a/tests/cloud_tests/platforms/lxd/instance.py
699+++ b/tests/cloud_tests/platforms/lxd/instance.py
700@@ -152,9 +152,8 @@ class LXDInstance(Instance):
701 return fp.read()
702
703 try:
704- stdout, stderr = subp(
705- ['lxc', 'console', '--show-log', self.name], decode=False)
706- return stdout
707+ return subp(['lxc', 'console', '--show-log', self.name],
708+ decode=False)[0]
709 except ProcessExecutionError as e:
710 raise PlatformError(
711 "console log",
712@@ -214,11 +213,10 @@ def _has_proper_console_support():
713 reason = "LXD Driver version not 3.x+ (%s)" % dver
714 else:
715 try:
716- stdout, stderr = subp(['lxc', 'console', '--help'],
717- decode=False)
718+ stdout = subp(['lxc', 'console', '--help'], decode=False)[0]
719 if not (b'console' in stdout and b'log' in stdout):
720 reason = "no '--log' in lxc console --help"
721- except ProcessExecutionError as e:
722+ except ProcessExecutionError:
723 reason = "no 'console' command in lxc client"
724
725 if reason:
726diff --git a/tests/cloud_tests/setup_image.py b/tests/cloud_tests/setup_image.py
727index 6d24211..4e19570 100644
728--- a/tests/cloud_tests/setup_image.py
729+++ b/tests/cloud_tests/setup_image.py
730@@ -25,10 +25,9 @@ def installed_package_version(image, package, ensure_installed=True):
731 else:
732 raise NotImplementedError
733
734- msg = 'query version for package: {}'.format(package)
735- (out, err, exit) = image.execute(
736- cmd, description=msg, rcs=(0,) if ensure_installed else range(0, 256))
737- return out.strip()
738+ return image.execute(
739+ cmd, description='query version for package: {}'.format(package),
740+ rcs=(0,) if ensure_installed else range(0, 256))[0].strip()
741
742
743 def install_deb(args, image):
744@@ -54,7 +53,7 @@ def install_deb(args, image):
745 remote_path], description=msg)
746 # check installed deb version matches package
747 fmt = ['-W', "--showformat=${Version}"]
748- (out, err, exit) = image.execute(['dpkg-deb'] + fmt + [remote_path])
749+ out = image.execute(['dpkg-deb'] + fmt + [remote_path])[0]
750 expected_version = out.strip()
751 found_version = installed_package_version(image, 'cloud-init')
752 if expected_version != found_version:
753@@ -85,7 +84,7 @@ def install_rpm(args, image):
754 image.execute(['rpm', '-U', remote_path], description=msg)
755
756 fmt = ['--queryformat', '"%{VERSION}"']
757- (out, err, exit) = image.execute(['rpm', '-q'] + fmt + [remote_path])
758+ (out, _err, _exit) = image.execute(['rpm', '-q'] + fmt + [remote_path])
759 expected_version = out.strip()
760 found_version = installed_package_version(image, 'cloud-init')
761 if expected_version != found_version:
762diff --git a/tests/cloud_tests/testcases/base.py b/tests/cloud_tests/testcases/base.py
763index 7598d46..e3dcab3 100644
764--- a/tests/cloud_tests/testcases/base.py
765+++ b/tests/cloud_tests/testcases/base.py
766@@ -159,7 +159,7 @@ class CloudTestCase(unittest.TestCase):
767 expected_net_keys = [
768 'public-ipv4s', 'ipv4-associations', 'local-hostname',
769 'public-hostname']
770- for mac, mac_data in macs.items():
771+ for mac_data in macs.values():
772 for key in expected_net_keys:
773 self.assertIn(key, mac_data)
774 self.assertIsNotNone(
775diff --git a/tests/cloud_tests/testcases/examples/including_user_groups.py b/tests/cloud_tests/testcases/examples/including_user_groups.py
776index 93b7a82..4067348 100644
777--- a/tests/cloud_tests/testcases/examples/including_user_groups.py
778+++ b/tests/cloud_tests/testcases/examples/including_user_groups.py
779@@ -42,7 +42,7 @@ class TestUserGroups(base.CloudTestCase):
780
781 def test_user_root_in_secret(self):
782 """Test root user is in 'secret' group."""
783- user, _, groups = self.get_data_file('root_groups').partition(":")
784+ _user, _, groups = self.get_data_file('root_groups').partition(":")
785 self.assertIn("secret", groups.split(),
786 msg="User root is not in group 'secret'")
787
788diff --git a/tests/cloud_tests/testcases/modules/user_groups.py b/tests/cloud_tests/testcases/modules/user_groups.py
789index 93b7a82..4067348 100644
790--- a/tests/cloud_tests/testcases/modules/user_groups.py
791+++ b/tests/cloud_tests/testcases/modules/user_groups.py
792@@ -42,7 +42,7 @@ class TestUserGroups(base.CloudTestCase):
793
794 def test_user_root_in_secret(self):
795 """Test root user is in 'secret' group."""
796- user, _, groups = self.get_data_file('root_groups').partition(":")
797+ _user, _, groups = self.get_data_file('root_groups').partition(":")
798 self.assertIn("secret", groups.split(),
799 msg="User root is not in group 'secret'")
800
801diff --git a/tests/cloud_tests/util.py b/tests/cloud_tests/util.py
802index 3dd4996..06f7d86 100644
803--- a/tests/cloud_tests/util.py
804+++ b/tests/cloud_tests/util.py
805@@ -358,7 +358,7 @@ class TargetBase(object):
806 # when sh is invoked with '-c', then the first argument is "$0"
807 # which is commonly understood as the "program name".
808 # 'read_data' is the program name, and 'remote_path' is '$1'
809- stdout, stderr, rc = self._execute(
810+ stdout, _stderr, rc = self._execute(
811 ["sh", "-c", 'exec cat "$1"', 'read_data', remote_path])
812 if rc != 0:
813 raise RuntimeError("Failed to read file '%s'" % remote_path)
814diff --git a/tests/unittests/test__init__.py b/tests/unittests/test__init__.py
815index 25878d7..f1ab02e 100644
816--- a/tests/unittests/test__init__.py
817+++ b/tests/unittests/test__init__.py
818@@ -214,7 +214,7 @@ class TestCmdlineUrl(CiTestCase):
819 def test_no_key_found(self, m_read):
820 cmdline = "ro mykey=http://example.com/foo root=foo"
821 fpath = self.tmp_path("ccpath")
822- lvl, msg = main.attempt_cmdline_url(
823+ lvl, _msg = main.attempt_cmdline_url(
824 fpath, network=True, cmdline=cmdline)
825
826 m_read.assert_not_called()
827diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
828index 3e8b791..88fe76c 100644
829--- a/tests/unittests/test_datasource/test_azure.py
830+++ b/tests/unittests/test_datasource/test_azure.py
831@@ -214,7 +214,7 @@ scbus-1 on xpt0 bus 0
832 self.assertIn(tag, x)
833
834 def tags_equal(x, y):
835- for x_tag, x_val in x.items():
836+ for x_val in x.values():
837 y_val = y.get(x_val.tag)
838 self.assertEqual(x_val.text, y_val.text)
839
840@@ -1216,7 +1216,7 @@ class TestAzureDataSourcePreprovisioning(CiTestCase):
841 fake_resp.return_value = mock.MagicMock(status_code=200, text=content,
842 content=content)
843 dsa = dsaz.DataSourceAzure({}, distro=None, paths=self.paths)
844- md, ud, cfg, d = dsa._reprovision()
845+ md, _ud, cfg, _d = dsa._reprovision()
846 self.assertEqual(md['local-hostname'], hostname)
847 self.assertEqual(cfg['system_info']['default_user']['name'], username)
848 self.assertEqual(fake_resp.call_args_list,
849diff --git a/tests/unittests/test_datasource/test_maas.py b/tests/unittests/test_datasource/test_maas.py
850index 6e4031c..c84d067 100644
851--- a/tests/unittests/test_datasource/test_maas.py
852+++ b/tests/unittests/test_datasource/test_maas.py
853@@ -53,7 +53,7 @@ class TestMAASDataSource(CiTestCase):
854 my_d = os.path.join(self.tmp, "valid_extra")
855 populate_dir(my_d, data)
856
857- ud, md, vd = DataSourceMAAS.read_maas_seed_dir(my_d)
858+ ud, md, _vd = DataSourceMAAS.read_maas_seed_dir(my_d)
859
860 self.assertEqual(userdata, ud)
861 for key in ('instance-id', 'local-hostname'):
862@@ -149,7 +149,7 @@ class TestMAASDataSource(CiTestCase):
863 'meta-data/local-hostname': 'test-hostname',
864 'meta-data/vendor-data': yaml.safe_dump(expected_vd).encode(),
865 }
866- ud, md, vd = self.mock_read_maas_seed_url(
867+ _ud, md, vd = self.mock_read_maas_seed_url(
868 valid, "http://example.com/foo")
869
870 self.assertEqual(valid['meta-data/instance-id'], md['instance-id'])
871diff --git a/tests/unittests/test_datasource/test_nocloud.py b/tests/unittests/test_datasource/test_nocloud.py
872index 70d50de..cdbd1e1 100644
873--- a/tests/unittests/test_datasource/test_nocloud.py
874+++ b/tests/unittests/test_datasource/test_nocloud.py
875@@ -51,9 +51,6 @@ class TestNoCloudDataSource(CiTestCase):
876 class PsuedoException(Exception):
877 pass
878
879- def my_find_devs_with(*args, **kwargs):
880- raise PsuedoException
881-
882 self.mocks.enter_context(
883 mock.patch.object(util, 'find_devs_with',
884 side_effect=PsuedoException))
885diff --git a/tests/unittests/test_handler/test_handler_apt_source_v3.py b/tests/unittests/test_handler/test_handler_apt_source_v3.py
886index 7bb1b7c..e486862 100644
887--- a/tests/unittests/test_handler/test_handler_apt_source_v3.py
888+++ b/tests/unittests/test_handler/test_handler_apt_source_v3.py
889@@ -528,7 +528,7 @@ class TestAptSourceConfig(t_help.FilesystemMockingTestCase):
890
891 expected = sorted([npre + suff for opre, npre, suff in files])
892 # create files
893- for (opre, npre, suff) in files:
894+ for (opre, _npre, suff) in files:
895 fpath = os.path.join(apt_lists_d, opre + suff)
896 util.write_file(fpath, content=fpath)
897
898diff --git a/tests/unittests/test_handler/test_handler_ntp.py b/tests/unittests/test_handler/test_handler_ntp.py
899index 02676aa..17c5355 100644
900--- a/tests/unittests/test_handler/test_handler_ntp.py
901+++ b/tests/unittests/test_handler/test_handler_ntp.py
902@@ -76,7 +76,7 @@ class TestNtp(FilesystemMockingTestCase):
903 template = TIMESYNCD_TEMPLATE
904 else:
905 template = NTP_TEMPLATE
906- (confpath, template_fn) = self._generate_template(template=template)
907+ (confpath, _template_fn) = self._generate_template(template=template)
908 ntpconfig = copy.deepcopy(dcfg[client])
909 ntpconfig['confpath'] = confpath
910 ntpconfig['template_name'] = os.path.basename(confpath)
911diff --git a/tests/unittests/test_templating.py b/tests/unittests/test_templating.py
912index 1080e13..20c87ef 100644
913--- a/tests/unittests/test_templating.py
914+++ b/tests/unittests/test_templating.py
915@@ -50,12 +50,12 @@ class TestTemplates(test_helpers.CiTestCase):
916 def test_detection(self):
917 blob = "## template:cheetah"
918
919- (template_type, renderer, contents) = templater.detect_template(blob)
920+ (template_type, _renderer, contents) = templater.detect_template(blob)
921 self.assertIn("cheetah", template_type)
922 self.assertEqual("", contents.strip())
923
924 blob = "blahblah $blah"
925- (template_type, renderer, contents) = templater.detect_template(blob)
926+ (template_type, _renderer, _contents) = templater.detect_template(blob)
927 self.assertIn("cheetah", template_type)
928 self.assertEqual(blob, contents)
929
930diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
931index 5010190..5637c4e 100644
932--- a/tests/unittests/test_util.py
933+++ b/tests/unittests/test_util.py
934@@ -772,11 +772,11 @@ class TestSubp(helpers.CiTestCase):
935
936 def test_subp_reads_env(self):
937 with mock.patch.dict("os.environ", values={'FOO': 'BAR'}):
938- out, err = util.subp(self.printenv + ['FOO'], capture=True)
939+ out, _err = util.subp(self.printenv + ['FOO'], capture=True)
940 self.assertEqual('FOO=BAR', out.splitlines()[0])
941
942 def test_subp_env_and_update_env(self):
943- out, err = util.subp(
944+ out, _err = util.subp(
945 self.printenv + ['FOO', 'HOME', 'K1', 'K2'], capture=True,
946 env={'FOO': 'BAR'},
947 update_env={'HOME': '/myhome', 'K2': 'V2'})
948@@ -786,7 +786,7 @@ class TestSubp(helpers.CiTestCase):
949 def test_subp_update_env(self):
950 extra = {'FOO': 'BAR', 'HOME': '/root', 'K1': 'V1'}
951 with mock.patch.dict("os.environ", values=extra):
952- out, err = util.subp(
953+ out, _err = util.subp(
954 self.printenv + ['FOO', 'HOME', 'K1', 'K2'], capture=True,
955 update_env={'HOME': '/myhome', 'K2': 'V2'})
956

Subscribers

People subscribed via source and target branches