From 3a666a131f048b25353a074377661abcb4534fe2 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 11 Aug 2022 09:50:32 -0700 Subject: [PATCH] Remove unused code. (#78499) --- lib/ansible/executor/module_common.py | 6 ------ lib/ansible/modules/async_wrapper.py | 1 - lib/ansible/parsing/plugin_docs.py | 3 --- lib/ansible/plugins/loader.py | 3 --- 4 files changed, 13 deletions(-) diff --git a/lib/ansible/executor/module_common.py b/lib/ansible/executor/module_common.py index 470b085190f..4d06acb2907 100644 --- a/lib/ansible/executor/module_common.py +++ b/lib/ansible/executor/module_common.py @@ -54,12 +54,6 @@ from collections import namedtuple import importlib.util import importlib.machinery -# if we're on a Python that doesn't have FNFError, redefine it as IOError (since that's what we'll see) -try: - FileNotFoundError -except NameError: - FileNotFoundError = IOError - display = Display() ModuleUtilsProcessEntry = namedtuple('ModuleUtilsProcessEntry', ['name_parts', 'is_ambiguous', 'has_redirected_child', 'is_optional']) diff --git a/lib/ansible/modules/async_wrapper.py b/lib/ansible/modules/async_wrapper.py index 7eea4c14f66..4b1a5b3232f 100644 --- a/lib/ansible/modules/async_wrapper.py +++ b/lib/ansible/modules/async_wrapper.py @@ -136,7 +136,6 @@ def _make_temp_dir(path): def jwrite(info): - global job_path jobfile = job_path + ".tmp" tjob = open(jobfile, "w") try: diff --git a/lib/ansible/parsing/plugin_docs.py b/lib/ansible/parsing/plugin_docs.py index 0e3ec839750..e4202ce709a 100644 --- a/lib/ansible/parsing/plugin_docs.py +++ b/lib/ansible/parsing/plugin_docs.py @@ -26,7 +26,6 @@ string_to_vars = { def _var2string(value): ''' reverse lookup of the dict above ''' - global string_to_vars for k, v in string_to_vars.items(): if v == value: return k @@ -40,7 +39,6 @@ def _init_doc_dict(): def read_docstring_from_yaml_file(filename, verbose=True, ignore_errors=True): ''' Read docs from 'sidecar' yaml file doc for a plugin ''' - global string_to_vars data = _init_doc_dict() file_data = {} @@ -117,7 +115,6 @@ def read_docstring_from_python_file(filename, verbose=True, ignore_errors=True): """ data = _init_doc_dict() - global string_to_vars try: with open(filename, 'rb') as b_module_data: diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py index 85cdaf8281c..ef72587b126 100644 --- a/lib/ansible/plugins/loader.py +++ b/lib/ansible/plugins/loader.py @@ -599,7 +599,6 @@ class PluginLoader: plugin_load_context.redirect_list.append(name) plugin_load_context.resolved = False - global _PLUGIN_FILTERS if name in _PLUGIN_FILTERS[self.package]: plugin_load_context.exit_reason = '{0} matched a defined plugin filter'.format(name) return plugin_load_context @@ -929,8 +928,6 @@ class PluginLoader: # Move _dedupe to be a class attribute, CUSTOM_DEDUPE, with subclasses for filters and # tests setting it to True - global _PLUGIN_FILTERS - dedupe = kwargs.pop('_dedupe', True) path_only = kwargs.pop('path_only', False) class_only = kwargs.pop('class_only', False)