diff --git a/contrib/inventory/docker.py b/contrib/inventory/docker.py index cc7b61e6d2..da051dd411 100755 --- a/contrib/inventory/docker.py +++ b/contrib/inventory/docker.py @@ -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)) diff --git a/contrib/inventory/linode.py b/contrib/inventory/linode.py index 1f54ba605b..6fd922fa6a 100755 --- a/contrib/inventory/linode.py +++ b/contrib/inventory/linode.py @@ -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.""" diff --git a/lib/ansible/module_utils/aos.py b/lib/ansible/module_utils/aos.py index 806e5194d2..42c60b8bb3 100644 --- a/lib/ansible/module_utils/aos.py +++ b/lib/ansible/module_utils/aos.py @@ -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") diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 448154cb7b..3327d1b2e2 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1855,7 +1855,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. diff --git a/lib/ansible/module_utils/docker_common.py b/lib/ansible/module_utils/docker_common.py index bdf64d0cfd..c143b2b2c6 100644 --- a/lib/ansible/module_utils/docker_common.py +++ b/lib/ansible/module_utils/docker_common.py @@ -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)) diff --git a/lib/ansible/modules/cloud/amazon/cloudformation.py b/lib/ansible/modules/cloud/amazon/cloudformation.py index 5fca87f1d1..2efde11c3c 100644 --- a/lib/ansible/modules/cloud/amazon/cloudformation.py +++ b/lib/ansible/modules/cloud/amazon/cloudformation.py @@ -373,7 +373,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 diff --git a/lib/ansible/modules/cloud/azure/azure.py b/lib/ansible/modules/cloud/azure/azure.py index c44a7e0ae8..a76630dac4 100644 --- a/lib/ansible/modules/cloud/azure/azure.py +++ b/lib/ansible/modules/cloud/azure/azure.py @@ -302,7 +302,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) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py index ecd5b52429..1f6d957479 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py @@ -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: diff --git a/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py b/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py index c7eac4f346..64330847fc 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py @@ -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)) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py index d87e0003ef..df7dcf6365 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py @@ -687,8 +687,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 @@ -886,7 +885,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): ''' diff --git a/lib/ansible/modules/cloud/misc/rhevm.py b/lib/ansible/modules/cloud/misc/rhevm.py index 36741a3ffc..b742ba7ec1 100644 --- a/lib/ansible/modules/cloud/misc/rhevm.py +++ b/lib/ansible/modules/cloud/misc/rhevm.py @@ -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) diff --git a/lib/ansible/modules/cloud/openstack/os_stack.py b/lib/ansible/modules/cloud/openstack/os_stack.py index 858dff5568..c466e935dd 100644 --- a/lib/ansible/modules/cloud/openstack/os_stack.py +++ b/lib/ansible/modules/cloud/openstack/os_stack.py @@ -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)) diff --git a/lib/ansible/playbook/become.py b/lib/ansible/playbook/become.py index 69a87bfe58..1ad5fbadd1 100644 --- a/lib/ansible/playbook/become.py +++ b/lib/ansible/playbook/become.py @@ -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): diff --git a/lib/ansible/plugins/lookup/consul_kv.py b/lib/ansible/plugins/lookup/consul_kv.py index 27cf3dbef3..c6d12d31c5 100644 --- a/lib/ansible/plugins/lookup/consul_kv.py +++ b/lib/ansible/plugins/lookup/consul_kv.py @@ -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) diff --git a/test/sanity/pylint/disable.txt b/test/sanity/pylint/disable.txt index 8241074587..55c2238f73 100644 --- a/test/sanity/pylint/disable.txt +++ b/test/sanity/pylint/disable.txt @@ -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