cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #03983
[Merge] ~chad.smith/cloud-init:tip-lint-fixes into cloud-init:master
Chad Smith has proposed merging ~chad.smith/cloud-init:tip-lint-fixes into cloud-init:master.
Requested reviews:
cloud-init commiters (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/335271
lint: Fix lints seen by pylint revision 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.
--
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:tip-lint-fixes into cloud-init:master.
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index 177cbcf..53e0fde 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -275,8 +275,9 @@ def handle(name, ocfg, cloud, log, _):
cfg = ocfg.get('apt', {})
if not isinstance(cfg, dict):
- raise ValueError("Expected dictionary for 'apt' config, found %s",
- type(cfg))
+ raise ValueError(
+ "Expected dictionary for 'apt' config, found {0}".format(
+ type(cfg)))
apply_debconf_selections(cfg, target)
apply_apt(cfg, cloud, target)
diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
index c2b83ae..a6216dc 100644
--- a/cloudinit/config/cc_disk_setup.py
+++ b/cloudinit/config/cc_disk_setup.py
@@ -788,7 +788,7 @@ def mkpart(device, definition):
# This prevents you from overwriting the device
LOG.debug("Checking if device %s is a valid device", device)
if not is_device_valid(device):
- raise Exception("Device %s is not a disk device!", device)
+ raise Exception('Device {0} is not a disk device!'.format(device))
# Remove the partition table entries
if isinstance(layout, str) and layout.lower() == "remove":
@@ -945,8 +945,8 @@ def mkfs(fs_cfg):
# Check that we can create the FS
if not (fs_type or fs_cmd):
- raise Exception("No way to create filesystem '%s'. fs_type or fs_cmd "
- "must be set.", label)
+ raise Exception("No way to create filesystem '{0}'. fs_type or fs_cmd "
+ "must be set.".format(label))
# Create the commands
shell = False
diff --git a/cloudinit/config/cc_landscape.py b/cloudinit/config/cc_landscape.py
index 8f9f1ab..a8a46e5 100644
--- a/cloudinit/config/cc_landscape.py
+++ b/cloudinit/config/cc_landscape.py
@@ -94,10 +94,9 @@ def handle(_name, cfg, cloud, log, _args):
ls_cloudcfg = cfg.get("landscape", {})
if not isinstance(ls_cloudcfg, (dict)):
- raise RuntimeError(("'landscape' key existed in config,"
- " but not a dictionary type,"
- " is a %s instead"),
- type_utils.obj_name(ls_cloudcfg))
+ raise RuntimeError(
+ "'landscape' key existed in config, but not a dictionary type,"
+ " is a {0} instead".format(type_utils.obj_name(ls_cloudcfg)))
if not ls_cloudcfg:
return
diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py
index f50bcb3..ac6298f 100644
--- a/cloudinit/config/cc_ntp.py
+++ b/cloudinit/config/cc_ntp.py
@@ -106,9 +106,9 @@ def handle(name, cfg, cloud, log, _args):
# TODO drop this when validate_cloudconfig_schema is strict=True
if not isinstance(ntp_cfg, (dict)):
- raise RuntimeError(("'ntp' key existed in config,"
- " but not a dictionary type,"
- " is a %s %instead"), type_utils.obj_name(ntp_cfg))
+ raise RuntimeError(
+ "'ntp' key existed in config, but not a dictionary type,"
+ " is a {0} instead".format(type_utils.obj_name(ntp_cfg)))
validate_cloudconfig_schema(cfg, schema)
if ntp_installable():
@@ -206,8 +206,8 @@ def write_ntp_config_template(cfg, cloud, path, template=None):
if not template_fn:
template_fn = cloud.get_template_filename('ntp.conf')
if not template_fn:
- raise RuntimeError(("No template found, "
- "not rendering %s"), path)
+ raise RuntimeError(
+ 'No template found, not rendering {0}'.format(path))
templater.render_to_file(template_fn, path, params)
diff --git a/cloudinit/config/cc_seed_random.py b/cloudinit/config/cc_seed_random.py
index e76b9c0..704457c 100644
--- a/cloudinit/config/cc_seed_random.py
+++ b/cloudinit/config/cc_seed_random.py
@@ -95,7 +95,8 @@ def handle_random_seed_command(command, required, env=None):
cmd = command[0]
if not util.which(cmd):
if required:
- raise ValueError("command '%s' not found but required=true", cmd)
+ raise ValueError(
+ "command '{0}' not found but required=true".format(cmd))
else:
LOG.debug("command '%s' not found for seed_command", cmd)
return
diff --git a/cloudinit/config/cc_snap_config.py b/cloudinit/config/cc_snap_config.py
index fe0cc73..c5c6029 100644
--- a/cloudinit/config/cc_snap_config.py
+++ b/cloudinit/config/cc_snap_config.py
@@ -87,7 +87,8 @@ def add_assertions(assertions=None):
assertions = []
if not isinstance(assertions, list):
- raise ValueError('assertion parameter was not a list: %s', assertions)
+ raise ValueError(
+ 'assertion parameter was not a list: {0}'.format(assertions))
snap_cmd = [SNAPPY_CMD, 'ack']
combined = "\n".join(assertions)
@@ -115,7 +116,8 @@ def add_snap_user(cfg=None):
cfg = {}
if not isinstance(cfg, dict):
- raise ValueError('configuration parameter was not a dict: %s', cfg)
+ raise ValueError(
+ 'configuration parameter was not a dict: {0}'.format(cfg))
snapuser = cfg.get('email', None)
if not snapuser:
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index 38b27a5..146db94 100755
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -116,10 +116,10 @@ def config_from_klibc_net_cfg(files=None, mac_addrs=None):
prev = names[name]['entry']
if prev.get('mac_address') != entry.get('mac_address'):
raise ValueError(
- "device '%s' was defined multiple times (%s)"
- " but had differing mac addresses: %s -> %s.",
- (name, ' '.join(names[name]['files']),
- prev.get('mac_address'), entry.get('mac_address')))
+ "device '{0}' was defined multiple times ({1})"
+ " but had differing mac addresses: {2} -> {3}.".format(
+ name, ' '.join(names[name]['files']),
+ prev.get('mac_address'), entry.get('mac_address')))
prev['subnets'].extend(entry['subnets'])
names[name]['files'].append(cfg_file)
else:
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index e9e2cf4..0ad6a8e 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -474,8 +474,9 @@ class NetworkStateInterpreter(object):
elif bridge_stp in ['off', '0', 0]:
bridge_stp = False
else:
- raise ValueError("Cannot convert bridge_stp value"
- "(%s) to boolean", bridge_stp)
+ raise ValueError(
+ 'Cannot convert bridge_stp value ({0}) to boolean'.format(
+ bridge_stp))
iface.update({'bridge_stp': bridge_stp})
interfaces.update({iface['name']: iface})
@@ -692,7 +693,7 @@ class NetworkStateInterpreter(object):
elif cmd_type == "bond":
self.handle_bond(v1_cmd)
else:
- raise ValueError('Unknown command type: %s', cmd_type)
+ raise ValueError('Unknown command type: {0}'.format(cmd_type))
def _v2_to_v1_ipcfg(self, cfg):
"""Common ipconfig extraction from v2 to v1 subnets array."""
diff --git a/cloudinit/sources/DataSourceAltCloud.py b/cloudinit/sources/DataSourceAltCloud.py
index be2d6cf..e1d0055 100644
--- a/cloudinit/sources/DataSourceAltCloud.py
+++ b/cloudinit/sources/DataSourceAltCloud.py
@@ -145,7 +145,7 @@ class DataSourceAltCloud(sources.DataSource):
else:
cloud_type = self.get_cloud_type()
- LOG.debug('cloud_type: ' + str(cloud_type))
+ LOG.debug('cloud_type: %s', str(cloud_type))
if 'RHEV' in cloud_type:
if self.user_data_rhevm():
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 6978d4e..e73b57b 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -582,12 +582,12 @@ def address_ephemeral_resize(devpath=RESOURCE_DISK_PATH, maxwait=120,
if os.path.exists(sempath):
try:
os.unlink(sempath)
- LOG.debug(bmsg + " removed.")
+ LOG.debug('%s removed.', bmsg)
except Exception as e:
# python3 throws FileNotFoundError, python2 throws OSError
- LOG.warning(bmsg + ": remove failed! (%s)", e)
+ LOG.warning('%s: remove failed! (%s)', bmsg, e)
else:
- LOG.debug(bmsg + " did not exist.")
+ LOG.debug('%s did not exist.', bmsg)
return
diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py
index 5da1184..858dd0d 100644
--- a/cloudinit/sources/DataSourceOpenNebula.py
+++ b/cloudinit/sources/DataSourceOpenNebula.py
@@ -332,8 +332,8 @@ def read_context_disk_dir(source_dir, asuser=None):
try:
pwd.getpwnam(asuser)
except KeyError as e:
- raise BrokenContextDiskDir("configured user '%s' "
- "does not exist", asuser)
+ raise BrokenContextDiskDir(
+ "configured user '{0}' does not exist".format(asuser))
try:
path = os.path.join(source_dir, 'context.sh')
content = util.load_file(path)
diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
index 959b1bd..6e619df 100644
--- a/cloudinit/sources/helpers/azure.py
+++ b/cloudinit/sources/helpers/azure.py
@@ -274,7 +274,8 @@ class WALinuxAgentShim(object):
name = os.path.basename(hook_file).replace('.json', '')
dhcp_options[name] = json.loads(util.load_file((hook_file)))
except ValueError:
- raise ValueError("%s is not valid JSON data", hook_file)
+ raise ValueError(
+ '{0} is not valid JSON data'.format(hook_file))
return dhcp_options
@staticmethod
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 11e96a7..ae3850d 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2327,7 +2327,7 @@ def pathprefix2dict(base, required=None, optional=None, delim=os.path.sep):
missing.append(f)
if len(missing):
- raise ValueError("Missing required files: %s", ','.join(missing))
+ raise ValueError('Missing required files: {0}'.format(','.join(missing)))
return ret
diff --git a/tox.ini b/tox.ini
index 0802072..fdc8a66 100644
--- a/tox.ini
+++ b/tox.ini
@@ -24,7 +24,7 @@ setenv =
basepython = python3
deps =
# requirements
- pylint==1.7.5
+ pylint==1.8.1
# test-requirements because unit tests are now present in cloudinit tree
-r{toxinidir}/test-requirements.txt
commands = {envpython} -m pylint {posargs:cloudinit tests tools}
Follow ups