Fix errors reported by pylint. (#23282)

* Fix pylint misplaced-bare-raise errors.
* Fix pylint return-in-init error.
* Fix pylint bad-format-character error.
* Fix pylint too-many-format-args errors.
* Fix pylint too-few-format-args errors.
* Fix pylint truncated-format-string error.
This commit is contained in:
Matt Clay 2017-04-06 16:58:16 -07:00 committed by GitHub
parent 9e1bf1c6f2
commit 48eeab8a53
15 changed files with 17 additions and 25 deletions

View file

@ -525,7 +525,7 @@ class AnsibleDockerClient(Client):
msg = "You asked for verification that Docker host name matches %s. The actual hostname is %s. " \
"Most likely you need to set DOCKER_TLS_HOSTNAME or pass tls_hostname with a value of %s. " \
"You may also use TLS without verification by setting the tls parameter to true." \
% (self.auth_params['tls_hostname'], match.group(1))
% (self.auth_params['tls_hostname'], match.group(1), match.group(1))
self.fail(msg)
self.fail("SSL Exception: %s" % (error))

View file

@ -197,7 +197,7 @@ class LinodeInventory(object):
try:
return Linode.find(api_id=linode_id)
except chube_api.linode_api.ApiError as e:
sys.exit("Looks like Linode's API is down:\n%" % e)
sys.exit("Looks like Linode's API is down:\n%s" % e)
def populate_datacenter_cache(self):
"""Creates self._datacenter_cache, containing all Datacenters indexed by ID."""

View file

@ -135,11 +135,11 @@ def content_to_dict(module, content):
content_dict = yaml.safe_load(content)
if not isinstance(content_dict, dict):
raise
raise Exception()
# Check if dict is empty and return an error if it's
if not content_dict:
raise
raise Exception()
except:
module.fail_json(msg="Unable to convert 'content' to a dict, please check if valid")

View file

@ -1882,7 +1882,7 @@ class AnsibleModule(object):
try:
cwd = os.getcwd()
if not os.access(cwd, os.F_OK|os.R_OK):
raise
raise Exception()
return cwd
except:
# we don't have access to the cwd, probably because of sudo.

View file

@ -330,7 +330,7 @@ class AnsibleDockerClient(Client):
msg = "You asked for verification that Docker host name matches %s. The actual hostname is %s. " \
"Most likely you need to set DOCKER_TLS_HOSTNAME or pass tls_hostname with a value of %s. " \
"You may also use TLS without verification by setting the tls parameter to true." \
% (self.auth_params['tls_hostname'], match.group(1))
% (self.auth_params['tls_hostname'], match.group(1), match.group(1))
self.fail(msg)
self.fail("SSL Exception: %s" % (error))

View file

@ -372,7 +372,7 @@ def get_stack_facts(cfn, stack_name):
#except AmazonCloudFormationException as e:
except (botocore.exceptions.ValidationError,botocore.exceptions.ClientError) as err:
error_msg = boto_exception(err)
if 'does not exist'.format(stack_name) in error_msg:
if 'does not exist' in error_msg:
# missing stack, don't bail.
return None

View file

@ -305,7 +305,7 @@ def _delete_disks_when_detached(azure, wait_timeout, disk_names):
azure.delete_disk(disk.name, True)
disk_names.remove(disk_name)
except AzureException as e:
module.fail_json(msg="failed to get or delete disk, error was: %s" % (disk_name, str(e)))
module.fail_json(msg="failed to get or delete disk %s, error was: %s" % (disk_name, str(e)))
finally:
signal.alarm(0)

View file

@ -211,7 +211,7 @@ class AzureRMNetworkInterfaceFacts(AzureRMModuleBase):
try:
response = self.network_client.network_interfaces.list_all()
except Exception as exc:
self.fail("Error listing all - {1}".format(self.resource_group, str(exc)))
self.fail("Error listing all - {0}".format(str(exc)))
results = []
for item in response:

View file

@ -200,8 +200,7 @@ class AzureRMResourceGroup(AzureRMModuleBase):
# Create resource group
self.log("Creating resource group {0}".format(self.name))
if not self.location:
self.fail("Parameter error: location is required when creating a resource "
"group.".format(self.name))
self.fail("Parameter error: location is required when creating a resource group.")
if self.name_exists():
self.fail("Error: a resource group with the name {0} already exists in your subscription."
.format(self.name))

View file

@ -688,8 +688,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
except CloudError:
self.log('Virtual machine {0} does not exist'.format(self.name))
if self.state == 'present':
self.log("CHANGED: virtual machine does not exist but state is present." \
.format(self.name))
self.log("CHANGED: virtual machine {0} does not exist but state is 'present'.".format(self.name))
changed = True
self.results['changed'] = changed
@ -887,7 +886,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
vm = self.compute_client.virtual_machines.get(self.resource_group, self.name, expand='instanceview')
return vm
except Exception as exc:
self.fail("Error getting virtual machine (0) - {1}".format(self.name, str(exc)))
self.fail("Error getting virtual machine {0} - {1}".format(self.name, str(exc)))
def serialize_vm(self, vm):
'''

View file

@ -449,7 +449,7 @@ class RHEVConn(object):
currentdisk = VM.disks.get(name=diskname)
if attempt == 100:
setMsg("Error, disk %s, state %s" % (diskname, str(currentdisk.status.state)))
raise
raise Exception()
else:
attempt += 1
time.sleep(2)
@ -489,7 +489,7 @@ class RHEVConn(object):
currentnic = VM.nics.get(name=nicname)
if attempt == 100:
setMsg("Error, iface %s, state %s" % (nicname, str(currentnic.active)))
raise
raise Exception()
else:
attempt += 1
time.sleep(2)

View file

@ -178,7 +178,7 @@ def _create_stack(module, stack, cloud):
return stack
else:
return False
module.fail_json(msg = "Failure in creating stack: ".format(stack))
module.fail_json(msg="Failure in creating stack: {0}".format(stack))
except shade.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -38,7 +38,7 @@ class Become:
_become_flags = FieldAttribute(isa='string')
def __init__(self):
return super(Become, self).__init__()
super(Become, self).__init__()
def _detect_privilege_escalation_conflict(self, ds):

View file

@ -125,7 +125,7 @@ class LookupModule(LookupBase):
for param in params[1:]:
if param and len(param) > 0:
name, value = param.split('=')
assert name in paramvals, "% not a valid consul lookup parameter" % name
assert name in paramvals, "%s not a valid consul lookup parameter" % name
paramvals[name] = value
except (ValueError, AssertionError) as e:
raise AnsibleError(e)

View file

@ -1,13 +1,11 @@
access-member-before-definition
assignment-from-no-return
bad-format-character
C
function-redefined
import-error
locally-disabled
locally-enabled
method-hidden
misplaced-bare-raise
no-member
no-name-in-module
no-value-for-parameter
@ -17,11 +15,7 @@ not-callable
R
raising-bad-type
raising-non-exception
return-in-init
too-few-format-args
too-many-format-args
too-many-function-args
truncated-format-string
undefined-variable
unexpected-keyword-arg
unsubscriptable-object