From ef7a74c4a3129437f25f9cc7b317ba1f43b25be4 Mon Sep 17 00:00:00 2001 From: beeankha Date: Mon, 24 Aug 2020 16:47:16 -0400 Subject: [PATCH 1/3] Initial commit of pylint fixes --- awx_collection/plugins/inventory/tower.py | 4 ++-- awx_collection/plugins/module_utils/tower_api.py | 4 ++-- awx_collection/plugins/module_utils/tower_awxkit.py | 2 +- awx_collection/plugins/module_utils/tower_legacy.py | 2 +- awx_collection/plugins/module_utils/tower_module.py | 8 ++++---- awx_collection/test/awx/conftest.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/awx_collection/plugins/inventory/tower.py b/awx_collection/plugins/inventory/tower.py index 7dc4aaa1a3..9ebc77923e 100644 --- a/awx_collection/plugins/inventory/tower.py +++ b/awx_collection/plugins/inventory/tower.py @@ -89,7 +89,7 @@ class InventoryModule(BaseInventoryPlugin): if path.endswith('@tower_inventory'): self.no_config_file_supplied = True return True - elif super(InventoryModule, self).verify_file(path): + elif super().verify_file(path): return path.endswith(('tower_inventory.yml', 'tower_inventory.yaml', 'tower.yml', 'tower.yaml')) else: return False @@ -98,7 +98,7 @@ class InventoryModule(BaseInventoryPlugin): self.display.warning(warning) def parse(self, inventory, loader, path, cache=True): - super(InventoryModule, self).parse(inventory, loader, path) + super().parse(inventory, loader, path) if not self.no_config_file_supplied and os.path.isfile(path): self._read_config_data(path) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index 6b5ed87531..a5cbb9b8aa 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -28,8 +28,8 @@ class TowerAPIModule(TowerModule): def __init__(self, argument_spec, direct_params=None, error_callback=None, warn_callback=None, **kwargs): kwargs['supports_check_mode'] = True - super(TowerAPIModule, self).__init__(argument_spec=argument_spec, direct_params=direct_params, - error_callback=error_callback, warn_callback=warn_callback, **kwargs) + super().__init__(argument_spec=argument_spec, direct_params=direct_params, + error_callback=error_callback, warn_callback=warn_callback, **kwargs) self.session = Request(cookies=CookieJar(), validate_certs=self.verify_ssl) @staticmethod diff --git a/awx_collection/plugins/module_utils/tower_awxkit.py b/awx_collection/plugins/module_utils/tower_awxkit.py index fc4e232f1b..62e8501861 100644 --- a/awx_collection/plugins/module_utils/tower_awxkit.py +++ b/awx_collection/plugins/module_utils/tower_awxkit.py @@ -20,7 +20,7 @@ class TowerAWXKitModule(TowerModule): def __init__(self, argument_spec, **kwargs): kwargs['supports_check_mode'] = False - super(TowerAWXKitModule, self).__init__(argument_spec=argument_spec, **kwargs) + super().__init__(argument_spec=argument_spec, **kwargs) # Die if we don't have AWX_KIT installed if not HAS_AWX_KIT: diff --git a/awx_collection/plugins/module_utils/tower_legacy.py b/awx_collection/plugins/module_utils/tower_legacy.py index 3c8408610d..660c315ef6 100644 --- a/awx_collection/plugins/module_utils/tower_legacy.py +++ b/awx_collection/plugins/module_utils/tower_legacy.py @@ -110,7 +110,7 @@ class TowerLegacyModule(AnsibleModule): ('tower_config_file', 'validate_certs'), )) - super(TowerLegacyModule, self).__init__(argument_spec=args, **kwargs) + super().__init__(argument_spec=args, **kwargs) if not HAS_TOWER_CLI: self.fail_json(msg=missing_required_lib('ansible-tower-cli'), diff --git a/awx_collection/plugins/module_utils/tower_module.py b/awx_collection/plugins/module_utils/tower_module.py index 553a35248c..3947a93448 100644 --- a/awx_collection/plugins/module_utils/tower_module.py +++ b/awx_collection/plugins/module_utils/tower_module.py @@ -71,7 +71,7 @@ class TowerModule(AnsibleModule): if direct_params is not None: self.params = direct_params else: - super(TowerModule, self).__init__(argument_spec=full_argspec, **kwargs) + super().__init__(argument_spec=full_argspec, **kwargs) self.load_config_files() @@ -225,15 +225,15 @@ class TowerModule(AnsibleModule): if self.error_callback: self.error_callback(**kwargs) else: - super(TowerModule, self).fail_json(**kwargs) + super().fail_json(**kwargs) def exit_json(self, **kwargs): # Try to log out if we are authenticated self.logout() - super(TowerModule, self).exit_json(**kwargs) + super().exit_json(**kwargs) def warn(self, warning): if self.warn_callback is not None: self.warn_callback(warning) else: - super(TowerModule, self).warn(warning) + super().warn(warning) diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index 5db00d6325..f032275958 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -187,7 +187,7 @@ def run_module(request, collection_import): try: result = json.loads(module_stdout) except Exception as e: - raise Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) + module.fail_json(msg='Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) # A module exception should never be a test expectation if 'exception' in result: if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']: From 4bc1a128ece9db84eb5bcf2d3ef07dc2d60fb9c5 Mon Sep 17 00:00:00 2001 From: beeankha Date: Tue, 25 Aug 2020 15:49:20 -0400 Subject: [PATCH 2/3] Add noqa directive for super calls --- awx_collection/plugins/inventory/tower.py | 4 ++-- awx_collection/plugins/module_utils/tower_api.py | 4 ++-- awx_collection/plugins/module_utils/tower_awxkit.py | 2 +- awx_collection/plugins/module_utils/tower_legacy.py | 2 +- awx_collection/plugins/module_utils/tower_module.py | 8 ++++---- awx_collection/test/awx/conftest.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/awx_collection/plugins/inventory/tower.py b/awx_collection/plugins/inventory/tower.py index 9ebc77923e..c86837e9a6 100644 --- a/awx_collection/plugins/inventory/tower.py +++ b/awx_collection/plugins/inventory/tower.py @@ -89,7 +89,7 @@ class InventoryModule(BaseInventoryPlugin): if path.endswith('@tower_inventory'): self.no_config_file_supplied = True return True - elif super().verify_file(path): + elif super(InventoryModule, self).verify_file(path): # noqa return path.endswith(('tower_inventory.yml', 'tower_inventory.yaml', 'tower.yml', 'tower.yaml')) else: return False @@ -98,7 +98,7 @@ class InventoryModule(BaseInventoryPlugin): self.display.warning(warning) def parse(self, inventory, loader, path, cache=True): - super().parse(inventory, loader, path) + super(InventoryModule, self).parse(inventory, loader, path) # noqa if not self.no_config_file_supplied and os.path.isfile(path): self._read_config_data(path) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index a5cbb9b8aa..e4c80ea541 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -28,8 +28,8 @@ class TowerAPIModule(TowerModule): def __init__(self, argument_spec, direct_params=None, error_callback=None, warn_callback=None, **kwargs): kwargs['supports_check_mode'] = True - super().__init__(argument_spec=argument_spec, direct_params=direct_params, - error_callback=error_callback, warn_callback=warn_callback, **kwargs) + super(TowerAPIModule, self).__init__(argument_spec=argument_spec, direct_params=direct_params, #noqa + error_callback=error_callback, warn_callback=warn_callback, **kwargs) self.session = Request(cookies=CookieJar(), validate_certs=self.verify_ssl) @staticmethod diff --git a/awx_collection/plugins/module_utils/tower_awxkit.py b/awx_collection/plugins/module_utils/tower_awxkit.py index 62e8501861..bfbf0cda5e 100644 --- a/awx_collection/plugins/module_utils/tower_awxkit.py +++ b/awx_collection/plugins/module_utils/tower_awxkit.py @@ -20,7 +20,7 @@ class TowerAWXKitModule(TowerModule): def __init__(self, argument_spec, **kwargs): kwargs['supports_check_mode'] = False - super().__init__(argument_spec=argument_spec, **kwargs) + super(TowerAWXKitModule, self).__init__(argument_spec=argument_spec, **kwargs) # noqa # Die if we don't have AWX_KIT installed if not HAS_AWX_KIT: diff --git a/awx_collection/plugins/module_utils/tower_legacy.py b/awx_collection/plugins/module_utils/tower_legacy.py index 660c315ef6..84dc2d9d0d 100644 --- a/awx_collection/plugins/module_utils/tower_legacy.py +++ b/awx_collection/plugins/module_utils/tower_legacy.py @@ -110,7 +110,7 @@ class TowerLegacyModule(AnsibleModule): ('tower_config_file', 'validate_certs'), )) - super().__init__(argument_spec=args, **kwargs) + super(TowerLegacyModule, self).__init__(argument_spec=args, **kwargs) # noqa if not HAS_TOWER_CLI: self.fail_json(msg=missing_required_lib('ansible-tower-cli'), diff --git a/awx_collection/plugins/module_utils/tower_module.py b/awx_collection/plugins/module_utils/tower_module.py index 3947a93448..0ce42d5731 100644 --- a/awx_collection/plugins/module_utils/tower_module.py +++ b/awx_collection/plugins/module_utils/tower_module.py @@ -71,7 +71,7 @@ class TowerModule(AnsibleModule): if direct_params is not None: self.params = direct_params else: - super().__init__(argument_spec=full_argspec, **kwargs) + super(TowerModule, self).__init__(argument_spec=full_argspec, **kwargs) # noqa self.load_config_files() @@ -225,15 +225,15 @@ class TowerModule(AnsibleModule): if self.error_callback: self.error_callback(**kwargs) else: - super().fail_json(**kwargs) + super(TowerModule, self).fail_json(**kwargs) # noqa def exit_json(self, **kwargs): # Try to log out if we are authenticated self.logout() - super().exit_json(**kwargs) + super(TowerModule, self).exit_json(**kwargs) # noqa def warn(self, warning): if self.warn_callback is not None: self.warn_callback(warning) else: - super().warn(warning) + super(TowerModule, self).warn(warning) # noqa diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index f032275958..bda9b0d518 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -187,7 +187,7 @@ def run_module(request, collection_import): try: result = json.loads(module_stdout) except Exception as e: - module.fail_json(msg='Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) + raise Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) # noqa # A module exception should never be a test expectation if 'exception' in result: if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']: From 3ddee3072b5f385638eaaf75b2b5615294513750 Mon Sep 17 00:00:00 2001 From: beeankha Date: Wed, 26 Aug 2020 11:55:13 -0400 Subject: [PATCH 3/3] Add errors to ignore file, remove noqa directives --- awx_collection/plugins/inventory/tower.py | 4 ++-- awx_collection/plugins/module_utils/tower_api.py | 2 +- awx_collection/plugins/module_utils/tower_awxkit.py | 2 +- awx_collection/plugins/module_utils/tower_legacy.py | 2 +- awx_collection/plugins/module_utils/tower_module.py | 8 ++++---- awx_collection/test/awx/conftest.py | 2 +- awx_collection/tests/sanity/ignore-2.10.txt | 9 +++++++++ awx_collection/tests/sanity/ignore-2.9.txt | 9 +++++++++ 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/awx_collection/plugins/inventory/tower.py b/awx_collection/plugins/inventory/tower.py index c86837e9a6..7dc4aaa1a3 100644 --- a/awx_collection/plugins/inventory/tower.py +++ b/awx_collection/plugins/inventory/tower.py @@ -89,7 +89,7 @@ class InventoryModule(BaseInventoryPlugin): if path.endswith('@tower_inventory'): self.no_config_file_supplied = True return True - elif super(InventoryModule, self).verify_file(path): # noqa + elif super(InventoryModule, self).verify_file(path): return path.endswith(('tower_inventory.yml', 'tower_inventory.yaml', 'tower.yml', 'tower.yaml')) else: return False @@ -98,7 +98,7 @@ class InventoryModule(BaseInventoryPlugin): self.display.warning(warning) def parse(self, inventory, loader, path, cache=True): - super(InventoryModule, self).parse(inventory, loader, path) # noqa + super(InventoryModule, self).parse(inventory, loader, path) if not self.no_config_file_supplied and os.path.isfile(path): self._read_config_data(path) diff --git a/awx_collection/plugins/module_utils/tower_api.py b/awx_collection/plugins/module_utils/tower_api.py index e4c80ea541..6b5ed87531 100644 --- a/awx_collection/plugins/module_utils/tower_api.py +++ b/awx_collection/plugins/module_utils/tower_api.py @@ -28,7 +28,7 @@ class TowerAPIModule(TowerModule): def __init__(self, argument_spec, direct_params=None, error_callback=None, warn_callback=None, **kwargs): kwargs['supports_check_mode'] = True - super(TowerAPIModule, self).__init__(argument_spec=argument_spec, direct_params=direct_params, #noqa + super(TowerAPIModule, self).__init__(argument_spec=argument_spec, direct_params=direct_params, error_callback=error_callback, warn_callback=warn_callback, **kwargs) self.session = Request(cookies=CookieJar(), validate_certs=self.verify_ssl) diff --git a/awx_collection/plugins/module_utils/tower_awxkit.py b/awx_collection/plugins/module_utils/tower_awxkit.py index bfbf0cda5e..fc4e232f1b 100644 --- a/awx_collection/plugins/module_utils/tower_awxkit.py +++ b/awx_collection/plugins/module_utils/tower_awxkit.py @@ -20,7 +20,7 @@ class TowerAWXKitModule(TowerModule): def __init__(self, argument_spec, **kwargs): kwargs['supports_check_mode'] = False - super(TowerAWXKitModule, self).__init__(argument_spec=argument_spec, **kwargs) # noqa + super(TowerAWXKitModule, self).__init__(argument_spec=argument_spec, **kwargs) # Die if we don't have AWX_KIT installed if not HAS_AWX_KIT: diff --git a/awx_collection/plugins/module_utils/tower_legacy.py b/awx_collection/plugins/module_utils/tower_legacy.py index 84dc2d9d0d..3c8408610d 100644 --- a/awx_collection/plugins/module_utils/tower_legacy.py +++ b/awx_collection/plugins/module_utils/tower_legacy.py @@ -110,7 +110,7 @@ class TowerLegacyModule(AnsibleModule): ('tower_config_file', 'validate_certs'), )) - super(TowerLegacyModule, self).__init__(argument_spec=args, **kwargs) # noqa + super(TowerLegacyModule, self).__init__(argument_spec=args, **kwargs) if not HAS_TOWER_CLI: self.fail_json(msg=missing_required_lib('ansible-tower-cli'), diff --git a/awx_collection/plugins/module_utils/tower_module.py b/awx_collection/plugins/module_utils/tower_module.py index 0ce42d5731..553a35248c 100644 --- a/awx_collection/plugins/module_utils/tower_module.py +++ b/awx_collection/plugins/module_utils/tower_module.py @@ -71,7 +71,7 @@ class TowerModule(AnsibleModule): if direct_params is not None: self.params = direct_params else: - super(TowerModule, self).__init__(argument_spec=full_argspec, **kwargs) # noqa + super(TowerModule, self).__init__(argument_spec=full_argspec, **kwargs) self.load_config_files() @@ -225,15 +225,15 @@ class TowerModule(AnsibleModule): if self.error_callback: self.error_callback(**kwargs) else: - super(TowerModule, self).fail_json(**kwargs) # noqa + super(TowerModule, self).fail_json(**kwargs) def exit_json(self, **kwargs): # Try to log out if we are authenticated self.logout() - super(TowerModule, self).exit_json(**kwargs) # noqa + super(TowerModule, self).exit_json(**kwargs) def warn(self, warning): if self.warn_callback is not None: self.warn_callback(warning) else: - super(TowerModule, self).warn(warning) # noqa + super(TowerModule, self).warn(warning) diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index bda9b0d518..5db00d6325 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -187,7 +187,7 @@ def run_module(request, collection_import): try: result = json.loads(module_stdout) except Exception as e: - raise Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) # noqa + raise Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) # A module exception should never be a test expectation if 'exception' in result: if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']: diff --git a/awx_collection/tests/sanity/ignore-2.10.txt b/awx_collection/tests/sanity/ignore-2.10.txt index 76f35a9a85..93f7dd6d7b 100644 --- a/awx_collection/tests/sanity/ignore-2.10.txt +++ b/awx_collection/tests/sanity/ignore-2.10.txt @@ -4,3 +4,12 @@ plugins/modules/tower_workflow_template.py validate-modules:deprecation-mismatch plugins/modules/tower_credential.py pylint:wrong-collection-deprecated-version-tag plugins/modules/tower_job_wait.py pylint:wrong-collection-deprecated-version-tag plugins/modules/tower_notification.py pylint:wrong-collection-deprecated-version-tag +plugins/inventory/tower.py pylint:raise-missing-from +plugins/inventory/tower.py pylint:super-with-arguments +plugins/lookup/tower_schedule_rrule.py pylint:raise-missing-from +plugins/module_utils/tower_api.py pylint:super-with-arguments +plugins/module_utils/tower_awxkit.py pylint:super-with-arguments +plugins/module_utils/tower_legacy.py pylint:super-with-arguments +plugins/module_utils/tower_module.py pylint:super-with-arguments +plugins/module_utils/tower_module.py pylint:raise-missing-from +test/awx/conftest.py pylint:raise-missing-from diff --git a/awx_collection/tests/sanity/ignore-2.9.txt b/awx_collection/tests/sanity/ignore-2.9.txt index 9242eefca9..f6ee755ea0 100644 --- a/awx_collection/tests/sanity/ignore-2.9.txt +++ b/awx_collection/tests/sanity/ignore-2.9.txt @@ -4,3 +4,12 @@ plugins/modules/tower_send.py validate-modules:deprecation-mismatch plugins/modules/tower_send.py validate-modules:invalid-documentation plugins/modules/tower_workflow_template.py validate-modules:deprecation-mismatch plugins/modules/tower_workflow_template.py validate-modules:invalid-documentation +plugins/inventory/tower.py pylint:raise-missing-from +plugins/inventory/tower.py pylint:super-with-arguments +plugins/lookup/tower_schedule_rrule.py pylint:raise-missing-from +plugins/module_utils/tower_api.py pylint:super-with-arguments +plugins/module_utils/tower_awxkit.py pylint:super-with-arguments +plugins/module_utils/tower_legacy.py pylint:super-with-arguments +plugins/module_utils/tower_module.py pylint:super-with-arguments +plugins/module_utils/tower_module.py pylint:raise-missing-from +test/awx/conftest.py pylint:raise-missing-from