diff --git a/bin/ansible b/bin/ansible index ffb79803f7b..6a40d9718f0 100755 --- a/bin/ansible +++ b/bin/ansible @@ -46,7 +46,7 @@ from ansible.module_utils._text import to_text ######################################## # OUTPUT OF LAST RESORT class LastResort(object): - def display(self, msg): + def display(self, msg, log_only=None): print(msg, file=sys.stderr) def error(self, msg, wrap_text=None): diff --git a/contrib/inventory/rax.py b/contrib/inventory/rax.py index dc3a8ed9838..a9e1be054b5 100755 --- a/contrib/inventory/rax.py +++ b/contrib/inventory/rax.py @@ -233,13 +233,17 @@ def _list_into_cache(regions): 'RAX_ACCESS_NETWORK', 'public', value_type='list') except TypeError: # Ansible 2.2.x and below + # pylint: disable=unexpected-keyword-arg networks = get_config(p, 'rax', 'access_network', 'RAX_ACCESS_NETWORK', 'public', islist=True) try: try: + # Ansible 2.3+ ip_versions = map(int, get_config(p, 'rax', 'access_ip_version', 'RAX_ACCESS_IP_VERSION', 4, value_type='list')) except TypeError: + # Ansible 2.2.x and below + # pylint: disable=unexpected-keyword-arg ip_versions = map(int, get_config(p, 'rax', 'access_ip_version', 'RAX_ACCESS_IP_VERSION', 4, islist=True)) except: @@ -438,6 +442,7 @@ def setup(): value_type='list') except TypeError: # Ansible 2.2.x and below + # pylint: disable=unexpected-keyword-arg region_list = get_config(p, 'rax', 'regions', 'RAX_REGION', 'all', islist=True) diff --git a/lib/ansible/cli/config.py b/lib/ansible/cli/config.py index b02dea95b4f..c0c8209c139 100644 --- a/lib/ansible/cli/config.py +++ b/lib/ansible/cli/config.py @@ -109,6 +109,7 @@ class ConfigCLI(CLI): ''' raise AnsibleError("Option not implemented yet") + # pylint: disable=unreachable if self.options.setting is None: raise AnsibleOptionsError("update option requries a setting to update") @@ -141,6 +142,8 @@ class ConfigCLI(CLI): Opens ansible.cfg in the default EDITOR ''' raise AnsibleError("Option not implemented yet") + + # pylint: disable=unreachable try: editor = shlex.split(os.environ.get('EDITOR','vi')) editor.append(self.config_file) diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 81ff613280c..74c179be000 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -643,7 +643,6 @@ class GalaxyCLI(CLI): if len(self.args) < 4: raise AnsibleError("Missing one or more arguments. Expecting: source github_user github_repo secret") - return 0 secret = self.args.pop() github_repo = self.args.pop() diff --git a/lib/ansible/config/data.py b/lib/ansible/config/data.py index fb947e88c13..c9adc51e400 100644 --- a/lib/ansible/config/data.py +++ b/lib/ansible/config/data.py @@ -42,4 +42,3 @@ class ConfigData(object): if plugin.name not in self._plugins[plugin.type]: self._plugins[plugin.type][plugin.name] = {} self._plugins[plugin.type][plugin.name][setting.name] = setting - diff --git a/lib/ansible/module_utils/redhat.py b/lib/ansible/module_utils/redhat.py index 7a6a90be378..358a2bd7b13 100644 --- a/lib/ansible/module_utils/redhat.py +++ b/lib/ansible/module_utils/redhat.py @@ -147,11 +147,6 @@ class Rhsm(RegistrationBase): * Boolean - whether the current system is currently registered to RHN. ''' - # Quick version... - if False: - return os.path.isfile('/etc/pki/consumer/cert.pem') and \ - os.path.isfile('/etc/pki/consumer/key.pem') - args = ['subscription-manager', 'identity'] rc, stdout, stderr = self.module.run_command(args, check_rc=False) if rc == 0: diff --git a/lib/ansible/modules/cloud/amazon/aws_kms.py b/lib/ansible/modules/cloud/amazon/aws_kms.py index 7ba4852c9d6..45fe303f053 100644 --- a/lib/ansible/modules/cloud/amazon/aws_kms.py +++ b/lib/ansible/modules/cloud/amazon/aws_kms.py @@ -293,4 +293,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/cloud/openstack/os_floating_ip.py b/lib/ansible/modules/cloud/openstack/os_floating_ip.py index 30046ff55c1..bd15f23a518 100644 --- a/lib/ansible/modules/cloud/openstack/os_floating_ip.py +++ b/lib/ansible/modules/cloud/openstack/os_floating_ip.py @@ -218,7 +218,7 @@ def main(): module.fail_json(msg="server {server} already has a " "floating-ip on requested " "interface but it doesn't match " - "requested network {network: {fip}" + "requested network {network}: {fip}" .format(server=server_name_or_id, network=network, fip=remove_values(f_ip, diff --git a/lib/ansible/modules/cloud/openstack/os_image_facts.py b/lib/ansible/modules/cloud/openstack/os_image_facts.py index 9ac7b784f4c..e2d8880f65e 100644 --- a/lib/ansible/modules/cloud/openstack/os_image_facts.py +++ b/lib/ansible/modules/cloud/openstack/os_image_facts.py @@ -167,4 +167,3 @@ from ansible.module_utils.basic import * from ansible.module_utils.openstack import * if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/asa/asa_command.py b/lib/ansible/modules/network/asa/asa_command.py index ee29a953efd..cc600a52a62 100644 --- a/lib/ansible/modules/network/asa/asa_command.py +++ b/lib/ansible/modules/network/asa/asa_command.py @@ -199,4 +199,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/fortios/fortios_config.py b/lib/ansible/modules/network/fortios/fortios_config.py index d63e5d99c4e..97559a9d0d6 100644 --- a/lib/ansible/modules/network/fortios/fortios_config.py +++ b/lib/ansible/modules/network/fortios/fortios_config.py @@ -181,4 +181,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/_nxos_mtu.py b/lib/ansible/modules/network/nxos/_nxos_mtu.py index 8402a567b56..53bc28074b7 100644 --- a/lib/ansible/modules/network/nxos/_nxos_mtu.py +++ b/lib/ansible/modules/network/nxos/_nxos_mtu.py @@ -381,4 +381,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py index f77773e5b48..c575e31e274 100644 --- a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py +++ b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py @@ -365,4 +365,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_gir.py b/lib/ansible/modules/network/nxos/nxos_gir.py index 58673d8f63f..e7cf944c747 100644 --- a/lib/ansible/modules/network/nxos/nxos_gir.py +++ b/lib/ansible/modules/network/nxos/nxos_gir.py @@ -318,4 +318,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py b/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py index 49667efd7e7..6cf220765f7 100644 --- a/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py +++ b/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py @@ -225,4 +225,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py b/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py index e76ff5c7dd1..a9c80a5a0d6 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py @@ -294,4 +294,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_ntp_auth.py b/lib/ansible/modules/network/nxos/nxos_ntp_auth.py index c75ca2c0293..a79a5866c69 100644 --- a/lib/ansible/modules/network/nxos/nxos_ntp_auth.py +++ b/lib/ansible/modules/network/nxos/nxos_ntp_auth.py @@ -325,4 +325,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_community.py b/lib/ansible/modules/network/nxos/nxos_snmp_community.py index 5e2b2f9dab1..ba952e0820e 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_community.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_community.py @@ -248,4 +248,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_contact.py b/lib/ansible/modules/network/nxos/nxos_snmp_contact.py index d6b1cfa1d4c..633bb6b33f7 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_contact.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_contact.py @@ -152,4 +152,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_host.py b/lib/ansible/modules/network/nxos/nxos_snmp_host.py index 10e669f54cb..77191746f80 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_host.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_host.py @@ -432,4 +432,3 @@ def main(): if __name__ == "__main__": main() - diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_traps.py b/lib/ansible/modules/network/nxos/nxos_snmp_traps.py index 15e8356183a..2fa12d92b2c 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_traps.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_traps.py @@ -289,4 +289,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_user.py b/lib/ansible/modules/network/nxos/nxos_snmp_user.py index 796cb2a08c3..1cb7e048e90 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_user.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_user.py @@ -351,4 +351,3 @@ def main(): if __name__ == "__main__": main() - diff --git a/lib/ansible/modules/network/nxos/nxos_udld.py b/lib/ansible/modules/network/nxos/nxos_udld.py index 93f2f7fca52..fa3aeec7677 100644 --- a/lib/ansible/modules/network/nxos/nxos_udld.py +++ b/lib/ansible/modules/network/nxos/nxos_udld.py @@ -295,4 +295,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/network/nxos/nxos_udld_interface.py b/lib/ansible/modules/network/nxos/nxos_udld_interface.py index 2c9d154b81a..80388b2cb02 100644 --- a/lib/ansible/modules/network/nxos/nxos_udld_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_udld_interface.py @@ -308,4 +308,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/storage/netapp/sf_account_manager.py b/lib/ansible/modules/storage/netapp/sf_account_manager.py index 575a17c8cff..467fc79a6c6 100644 --- a/lib/ansible/modules/storage/netapp/sf_account_manager.py +++ b/lib/ansible/modules/storage/netapp/sf_account_manager.py @@ -270,4 +270,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/modules/storage/netapp/sf_volume_manager.py b/lib/ansible/modules/storage/netapp/sf_volume_manager.py index 7a5a9b31eb7..61aa7817934 100644 --- a/lib/ansible/modules/storage/netapp/sf_volume_manager.py +++ b/lib/ansible/modules/storage/netapp/sf_volume_manager.py @@ -329,4 +329,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 37e8faeb43d..00dd23fa078 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -532,7 +532,7 @@ class ActionBase(with_metaclass(ABCMeta, object)): elif 'json' in errormsg or 'simplejson' in errormsg: x = "5" # json or simplejson modules needed finally: - return x + return x # pylint: disable=lost-exception def _remote_expand_user(self, path, sudoable=True): ''' takes a remote path and performs tilde expansion on the remote host ''' diff --git a/lib/ansible/plugins/cliconf/junos.py b/lib/ansible/plugins/cliconf/junos.py index a3cbf4c2dc2..4327f3d10bd 100644 --- a/lib/ansible/plugins/cliconf/junos.py +++ b/lib/ansible/plugins/cliconf/junos.py @@ -60,7 +60,7 @@ class Cliconf(CliconfBase): cmd = b'show configuration' else: cmd = b'show configuration | display %s' % format - return self.send_command(to_bytes(cmd), errors='surrogate_or_strict') + return self.send_command(to_bytes(cmd, errors='surrogate_or_strict')) def edit_config(self, command): for cmd in chain([b'configure'], to_list(command)): diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 1755c64a66c..0bfaa74e5d1 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -589,6 +589,7 @@ class Connection(ConnectionBase): # Make sure stdin is a proper pty to avoid tcgetattr errors master, slave = pty.openpty() if PY3 and self._play_context.password: + # pylint: disable=unexpected-keyword-arg p = subprocess.Popen(cmd, stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE, pass_fds=self.sshpass_pipe) else: p = subprocess.Popen(cmd, stdin=slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -599,6 +600,7 @@ class Connection(ConnectionBase): if not p: if PY3 and self._play_context.password: + # pylint: disable=unexpected-keyword-arg p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, pass_fds=self.sshpass_pipe) else: p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) diff --git a/lib/ansible/plugins/lookup/etcd.py b/lib/ansible/plugins/lookup/etcd.py index d6b9a1d6a5e..4a418a3da61 100644 --- a/lib/ansible/plugins/lookup/etcd.py +++ b/lib/ansible/plugins/lookup/etcd.py @@ -139,7 +139,6 @@ class Etcd: value = "ENOENT" except: raise - pass return value diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 3766f2e89ca..26c03c03cb8 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -114,7 +114,6 @@ lib/ansible/modules/cloud/misc/virt_pool.py lib/ansible/modules/cloud/misc/xenserver_facts.py lib/ansible/modules/cloud/openstack/os_group.py lib/ansible/modules/cloud/openstack/os_image.py -lib/ansible/modules/cloud/openstack/os_image_facts.py lib/ansible/modules/cloud/openstack/os_ironic.py lib/ansible/modules/cloud/openstack/os_keypair.py lib/ansible/modules/cloud/openstack/os_keystone_domain.py @@ -310,7 +309,6 @@ lib/ansible/modules/network/nxos/nxos_overlay_global.py lib/ansible/modules/network/nxos/nxos_ping.py lib/ansible/modules/network/nxos/nxos_smu.py lib/ansible/modules/network/nxos/nxos_snapshot.py -lib/ansible/modules/network/nxos/nxos_snmp_community.py lib/ansible/modules/network/nxos/nxos_snmp_contact.py lib/ansible/modules/network/nxos/nxos_snmp_host.py lib/ansible/modules/network/nxos/nxos_snmp_traps.py @@ -410,7 +408,6 @@ lib/ansible/modules/storage/netapp/na_cdot_qtree.py lib/ansible/modules/storage/netapp/na_cdot_volume.py lib/ansible/modules/storage/netapp/netapp_e_amg.py lib/ansible/modules/storage/netapp/netapp_e_storagepool.py -lib/ansible/modules/storage/netapp/sf_account_manager.py lib/ansible/modules/storage/netapp/sf_snapshot_schedule_manager.py lib/ansible/modules/storage/netapp/sf_volume_access_group_manager.py lib/ansible/modules/storage/netapp/sf_volume_manager.py diff --git a/test/sanity/pylint/disable.txt b/test/sanity/pylint/disable.txt index c318711648b..82ee589a3c7 100644 --- a/test/sanity/pylint/disable.txt +++ b/test/sanity/pylint/disable.txt @@ -6,7 +6,6 @@ arguments-differ assignment-from-no-return attribute-defined-outside-init bad-continuation -bad-format-string bad-indentation bad-mcs-classmethod-argument bad-open-mode @@ -20,7 +19,6 @@ consider-using-enumerate deprecated-lambda deprecated-method deprecated-module -duplicate-key eval-used exec-used expression-not-assigned @@ -38,7 +36,6 @@ line-too-long locally-disabled logging-format-interpolation logging-not-lazy -lost-exception method-hidden misplaced-comparison-constant missing-docstring @@ -80,9 +77,7 @@ too-many-nested-blocks too-many-public-methods too-many-return-statements too-many-statements -trailing-newlines undefined-loop-variable -unexpected-keyword-arg ungrouped-imports unidiomatic-typecheck unnecessary-lambda @@ -97,8 +92,6 @@ unused-variable unused-wildcard-import used-before-assignment useless-else-on-loop -useless-suppression -using-constant-test wildcard-import wrong-import-order wrong-import-position diff --git a/test/units/modules/network/netscaler/test_netscaler_cs_action.py b/test/units/modules/network/netscaler/test_netscaler_cs_action.py index 4e7d5a3559a..bea60ca9404 100644 --- a/test/units/modules/network/netscaler/test_netscaler_cs_action.py +++ b/test/units/modules/network/netscaler/test_netscaler_cs_action.py @@ -41,7 +41,6 @@ class TestNetscalerCSActionModule(TestModule): nssrc_modules_mock = { 'nssrc.com.citrix.netscaler.nitro.resource.config.cs': m, 'nssrc.com.citrix.netscaler.nitro.resource.config.cs.csaction': m, - 'nssrc.com.citrix.netscaler.nitro.resource.config.cs.csaction': m, 'nssrc.com.citrix.netscaler.nitro.resource.config.cs.csaction.csaction': cls.cs_action_mock, } diff --git a/test/units/modules/system/interfaces_file/test_interfaces_file.py b/test/units/modules/system/interfaces_file/test_interfaces_file.py index 1e275d87efd..717cea6d372 100644 --- a/test/units/modules/system/interfaces_file/test_interfaces_file.py +++ b/test/units/modules/system/interfaces_file/test_interfaces_file.py @@ -33,7 +33,6 @@ class AnsibleFailJson(Exception): class ModuleMocked(): def fail_json(self, msg): raise AnsibleFailJson(msg) - pass module = ModuleMocked() diff --git a/test/units/vars/test_variable_manager.py b/test/units/vars/test_variable_manager.py index 5f16a883c17..bb92cc0a513 100644 --- a/test/units/vars/test_variable_manager.py +++ b/test/units/vars/test_variable_manager.py @@ -104,6 +104,7 @@ class TestVariableManager(unittest.TestCase): # FIXME: BCS make this work return + # pylint: disable=unreachable fake_loader = DictDataLoader({}) mock_task = MagicMock() @@ -134,6 +135,8 @@ class TestVariableManager(unittest.TestCase): def test_variable_manager_precedence(self): # FIXME: this needs to be redone as dataloader is not the automatic source of data anymore return + + # pylint: disable=unreachable ''' Tests complex variations and combinations of get_vars() with different objects to modify the context under which variables are merged.