Merge ~chad.smith/cloud-init:tip-lint-fixes into cloud-init:master

Proposed by Chad Smith on 2017-12-15
Status: Merged
Approved by: Chad Smith on 2017-12-15
Approved revision: fde87929c11e622bbdb4fb08780bc495d246993c
Merge reported by: Chad Smith
Merged at revision: c6a6f59e80f1fd62562b1fe9acfd45e1cee3cbe8
Proposed branch: ~chad.smith/cloud-init:tip-lint-fixes
Merge into: cloud-init:master
Diff against target: 264 lines (+46/-33)
14 files modified
cloudinit/config/cc_apt_configure.py (+3/-2)
cloudinit/config/cc_disk_setup.py (+5/-3)
cloudinit/config/cc_landscape.py (+4/-4)
cloudinit/config/cc_ntp.py (+5/-5)
cloudinit/config/cc_seed_random.py (+2/-1)
cloudinit/config/cc_snap_config.py (+5/-2)
cloudinit/net/cmdline.py (+5/-4)
cloudinit/net/network_state.py (+5/-3)
cloudinit/sources/DataSourceAltCloud.py (+1/-1)
cloudinit/sources/DataSourceAzure.py (+3/-3)
cloudinit/sources/DataSourceOpenNebula.py (+3/-2)
cloudinit/sources/helpers/azure.py (+2/-1)
cloudinit/util.py (+2/-1)
tox.ini (+1/-1)
Reviewer Review Type Date Requested Status
Chad Smith Needs Fixing on 2017-12-15
Server Team CI bot continuous-integration Approve on 2017-12-15
Scott Moser 2017-12-15 Approve on 2017-12-15
Review via email: mp+335271@code.launchpad.net

Commit Message

lint: Fix lints seen by pylint version 1.8.1.

This branch resolves lints seen by pylint revision 1.8.1 and updates our
pinned tox pylint dependency used by our tox pylint target.

Description of the Change

lint: Fix lints seen by pylint version 1.8.1.

This branch resolves lints seen by pylint revision 1.8.1 and updates our
pinned tox pylint dependency used by our tox pylint target.

To post a comment you must log in.

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

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

review: Needs Fixing (continuous-integration)
eb46da6... by Chad Smith on 2017-12-15

flakes

Scott Moser (smoser) wrote :

assuming c-i approves, i approve.

review: Approve

PASSED: Continuous integration, rev:eb46da66cb6b138cfa3a6599a2668e5346d76357
https://jenkins.ubuntu.com/server/job/cloud-init-ci/639/
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/639/rebuild

review: Approve (continuous-integration)
fde8792... by Chad Smith on 2017-12-15

be explicit for formatted args since we are using .format

PASSED: Continuous integration, rev:fde87929c11e622bbdb4fb08780bc495d246993c
https://jenkins.ubuntu.com/server/job/cloud-init-ci/640/
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/640/rebuild

review: Approve (continuous-integration)
Chad Smith (chad.smith) wrote :

Looks great Josh thanks. I have some inline comments to resolve regarding using filters to find existing cloud-init resources in ec2 and using waiter methods. I've added a couple of discussion points about the potential of reusing or updating a named/tagged ssh key instead of use creating new ones. But, maybe we need to have that ssh discussion as a squad instead of on this branch.

Also a patch for better informing us about the required aws configuration files:
 http://paste.ubuntu.com/26190886/

Chad Smith (chad.smith) wrote :

Thank you for your merge proposal.

Your branch has been set to 'Work in progress'.
Please set the branch back to 'Needs Review' after resolving the issues below.

Thanks again,
Your friendly neighborhood cloud-init robot.

Your branch /tip-lint-fixes needs a final commit message which observes our
commit message guidelines before it can be reviewed and landed.

1. All lines must be less than 74 characters.
2. The commit message listed in launchpad needs to have the format:

A one-liner subject line

More detailed paragraphs describing the functional changes of the
branch.

LP: #<bug-id> # if it fixes a specific bug

Please fix the following errors:
------------------------------
The merge proposal /tip-lint-fixes does not have a commit message
------------------------------

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
2index 177cbcf..5b9cbca 100644
3--- a/cloudinit/config/cc_apt_configure.py
4+++ b/cloudinit/config/cc_apt_configure.py
5@@ -275,8 +275,9 @@ def handle(name, ocfg, cloud, log, _):
6 cfg = ocfg.get('apt', {})
7
8 if not isinstance(cfg, dict):
9- raise ValueError("Expected dictionary for 'apt' config, found %s",
10- type(cfg))
11+ raise ValueError(
12+ "Expected dictionary for 'apt' config, found {config_type}".format(
13+ config_type=type(cfg)))
14
15 apply_debconf_selections(cfg, target)
16 apply_apt(cfg, cloud, target)
17diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
18index c2b83ae..c3e8c48 100644
19--- a/cloudinit/config/cc_disk_setup.py
20+++ b/cloudinit/config/cc_disk_setup.py
21@@ -788,7 +788,8 @@ def mkpart(device, definition):
22 # This prevents you from overwriting the device
23 LOG.debug("Checking if device %s is a valid device", device)
24 if not is_device_valid(device):
25- raise Exception("Device %s is not a disk device!", device)
26+ raise Exception(
27+ 'Device {device} is not a disk device!'.format(device=device))
28
29 # Remove the partition table entries
30 if isinstance(layout, str) and layout.lower() == "remove":
31@@ -945,8 +946,9 @@ def mkfs(fs_cfg):
32
33 # Check that we can create the FS
34 if not (fs_type or fs_cmd):
35- raise Exception("No way to create filesystem '%s'. fs_type or fs_cmd "
36- "must be set.", label)
37+ raise Exception(
38+ "No way to create filesystem '{label}'. fs_type or fs_cmd "
39+ "must be set.".format(label=label))
40
41 # Create the commands
42 shell = False
43diff --git a/cloudinit/config/cc_landscape.py b/cloudinit/config/cc_landscape.py
44index 8f9f1ab..eaf1e94 100644
45--- a/cloudinit/config/cc_landscape.py
46+++ b/cloudinit/config/cc_landscape.py
47@@ -94,10 +94,10 @@ def handle(_name, cfg, cloud, log, _args):
48 ls_cloudcfg = cfg.get("landscape", {})
49
50 if not isinstance(ls_cloudcfg, (dict)):
51- raise RuntimeError(("'landscape' key existed in config,"
52- " but not a dictionary type,"
53- " is a %s instead"),
54- type_utils.obj_name(ls_cloudcfg))
55+ raise RuntimeError(
56+ "'landscape' key existed in config, but not a dictionary type,"
57+ " is a {_type} instead".format(
58+ _type=type_utils.obj_name(ls_cloudcfg)))
59 if not ls_cloudcfg:
60 return
61
62diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py
63index f50bcb3..cbd0237 100644
64--- a/cloudinit/config/cc_ntp.py
65+++ b/cloudinit/config/cc_ntp.py
66@@ -106,9 +106,9 @@ def handle(name, cfg, cloud, log, _args):
67
68 # TODO drop this when validate_cloudconfig_schema is strict=True
69 if not isinstance(ntp_cfg, (dict)):
70- raise RuntimeError(("'ntp' key existed in config,"
71- " but not a dictionary type,"
72- " is a %s %instead"), type_utils.obj_name(ntp_cfg))
73+ raise RuntimeError(
74+ "'ntp' key existed in config, but not a dictionary type,"
75+ " is a {_type} instead".format(_type=type_utils.obj_name(ntp_cfg)))
76
77 validate_cloudconfig_schema(cfg, schema)
78 if ntp_installable():
79@@ -206,8 +206,8 @@ def write_ntp_config_template(cfg, cloud, path, template=None):
80 if not template_fn:
81 template_fn = cloud.get_template_filename('ntp.conf')
82 if not template_fn:
83- raise RuntimeError(("No template found, "
84- "not rendering %s"), path)
85+ raise RuntimeError(
86+ 'No template found, not rendering {path}'.format(path=path))
87
88 templater.render_to_file(template_fn, path, params)
89
90diff --git a/cloudinit/config/cc_seed_random.py b/cloudinit/config/cc_seed_random.py
91index e76b9c0..65f6e77 100644
92--- a/cloudinit/config/cc_seed_random.py
93+++ b/cloudinit/config/cc_seed_random.py
94@@ -95,7 +95,8 @@ def handle_random_seed_command(command, required, env=None):
95 cmd = command[0]
96 if not util.which(cmd):
97 if required:
98- raise ValueError("command '%s' not found but required=true", cmd)
99+ raise ValueError(
100+ "command '{cmd}' not found but required=true".format(cmd=cmd))
101 else:
102 LOG.debug("command '%s' not found for seed_command", cmd)
103 return
104diff --git a/cloudinit/config/cc_snap_config.py b/cloudinit/config/cc_snap_config.py
105index fe0cc73..e82c081 100644
106--- a/cloudinit/config/cc_snap_config.py
107+++ b/cloudinit/config/cc_snap_config.py
108@@ -87,7 +87,9 @@ def add_assertions(assertions=None):
109 assertions = []
110
111 if not isinstance(assertions, list):
112- raise ValueError('assertion parameter was not a list: %s', assertions)
113+ raise ValueError(
114+ 'assertion parameter was not a list: {assertions}'.format(
115+ assertions=assertions))
116
117 snap_cmd = [SNAPPY_CMD, 'ack']
118 combined = "\n".join(assertions)
119@@ -115,7 +117,8 @@ def add_snap_user(cfg=None):
120 cfg = {}
121
122 if not isinstance(cfg, dict):
123- raise ValueError('configuration parameter was not a dict: %s', cfg)
124+ raise ValueError(
125+ 'configuration parameter was not a dict: {cfg}'.format(cfg=cfg))
126
127 snapuser = cfg.get('email', None)
128 if not snapuser:
129diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
130index 38b27a5..7b2cc9d 100755
131--- a/cloudinit/net/cmdline.py
132+++ b/cloudinit/net/cmdline.py
133@@ -116,10 +116,11 @@ def config_from_klibc_net_cfg(files=None, mac_addrs=None):
134 prev = names[name]['entry']
135 if prev.get('mac_address') != entry.get('mac_address'):
136 raise ValueError(
137- "device '%s' was defined multiple times (%s)"
138- " but had differing mac addresses: %s -> %s.",
139- (name, ' '.join(names[name]['files']),
140- prev.get('mac_address'), entry.get('mac_address')))
141+ "device '{name}' was defined multiple times ({files})"
142+ " but had differing mac addresses: {old} -> {new}.".format(
143+ name=name, files=' '.join(names[name]['files']),
144+ old=prev.get('mac_address'),
145+ new=entry.get('mac_address')))
146 prev['subnets'].extend(entry['subnets'])
147 names[name]['files'].append(cfg_file)
148 else:
149diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
150index e9e2cf4..31738c7 100644
151--- a/cloudinit/net/network_state.py
152+++ b/cloudinit/net/network_state.py
153@@ -474,8 +474,9 @@ class NetworkStateInterpreter(object):
154 elif bridge_stp in ['off', '0', 0]:
155 bridge_stp = False
156 else:
157- raise ValueError("Cannot convert bridge_stp value"
158- "(%s) to boolean", bridge_stp)
159+ raise ValueError(
160+ 'Cannot convert bridge_stp value ({stp}) to'
161+ ' boolean'.format(stp=bridge_stp))
162 iface.update({'bridge_stp': bridge_stp})
163
164 interfaces.update({iface['name']: iface})
165@@ -692,7 +693,8 @@ class NetworkStateInterpreter(object):
166 elif cmd_type == "bond":
167 self.handle_bond(v1_cmd)
168 else:
169- raise ValueError('Unknown command type: %s', cmd_type)
170+ raise ValueError('Unknown command type: {cmd_type}'.format(
171+ cmd_type=cmd_type))
172
173 def _v2_to_v1_ipcfg(self, cfg):
174 """Common ipconfig extraction from v2 to v1 subnets array."""
175diff --git a/cloudinit/sources/DataSourceAltCloud.py b/cloudinit/sources/DataSourceAltCloud.py
176index be2d6cf..e1d0055 100644
177--- a/cloudinit/sources/DataSourceAltCloud.py
178+++ b/cloudinit/sources/DataSourceAltCloud.py
179@@ -145,7 +145,7 @@ class DataSourceAltCloud(sources.DataSource):
180 else:
181 cloud_type = self.get_cloud_type()
182
183- LOG.debug('cloud_type: ' + str(cloud_type))
184+ LOG.debug('cloud_type: %s', str(cloud_type))
185
186 if 'RHEV' in cloud_type:
187 if self.user_data_rhevm():
188diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
189index 6978d4e..e73b57b 100644
190--- a/cloudinit/sources/DataSourceAzure.py
191+++ b/cloudinit/sources/DataSourceAzure.py
192@@ -582,12 +582,12 @@ def address_ephemeral_resize(devpath=RESOURCE_DISK_PATH, maxwait=120,
193 if os.path.exists(sempath):
194 try:
195 os.unlink(sempath)
196- LOG.debug(bmsg + " removed.")
197+ LOG.debug('%s removed.', bmsg)
198 except Exception as e:
199 # python3 throws FileNotFoundError, python2 throws OSError
200- LOG.warning(bmsg + ": remove failed! (%s)", e)
201+ LOG.warning('%s: remove failed! (%s)', bmsg, e)
202 else:
203- LOG.debug(bmsg + " did not exist.")
204+ LOG.debug('%s did not exist.', bmsg)
205 return
206
207
208diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py
209index 5da1184..f66c95d 100644
210--- a/cloudinit/sources/DataSourceOpenNebula.py
211+++ b/cloudinit/sources/DataSourceOpenNebula.py
212@@ -332,8 +332,9 @@ def read_context_disk_dir(source_dir, asuser=None):
213 try:
214 pwd.getpwnam(asuser)
215 except KeyError as e:
216- raise BrokenContextDiskDir("configured user '%s' "
217- "does not exist", asuser)
218+ raise BrokenContextDiskDir(
219+ "configured user '{user}' does not exist".format(
220+ user=asuser))
221 try:
222 path = os.path.join(source_dir, 'context.sh')
223 content = util.load_file(path)
224diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
225index 959b1bd..6cda572 100644
226--- a/cloudinit/sources/helpers/azure.py
227+++ b/cloudinit/sources/helpers/azure.py
228@@ -274,7 +274,8 @@ class WALinuxAgentShim(object):
229 name = os.path.basename(hook_file).replace('.json', '')
230 dhcp_options[name] = json.loads(util.load_file((hook_file)))
231 except ValueError:
232- raise ValueError("%s is not valid JSON data", hook_file)
233+ raise ValueError(
234+ '{_file} is not valid JSON data'.format(_file=hook_file))
235 return dhcp_options
236
237 @staticmethod
238diff --git a/cloudinit/util.py b/cloudinit/util.py
239index 11e96a7..8a9f1ab 100644
240--- a/cloudinit/util.py
241+++ b/cloudinit/util.py
242@@ -2327,7 +2327,8 @@ def pathprefix2dict(base, required=None, optional=None, delim=os.path.sep):
243 missing.append(f)
244
245 if len(missing):
246- raise ValueError("Missing required files: %s", ','.join(missing))
247+ raise ValueError(
248+ 'Missing required files: {files}'.format(files=','.join(missing)))
249
250 return ret
251
252diff --git a/tox.ini b/tox.ini
253index 0802072..fdc8a66 100644
254--- a/tox.ini
255+++ b/tox.ini
256@@ -24,7 +24,7 @@ setenv =
257 basepython = python3
258 deps =
259 # requirements
260- pylint==1.7.5
261+ pylint==1.8.1
262 # test-requirements because unit tests are now present in cloudinit tree
263 -r{toxinidir}/test-requirements.txt
264 commands = {envpython} -m pylint {posargs:cloudinit tests tools}

Subscribers

People subscribed via source and target branches