diff options
author | Matt Clay <matt@mystile.com> | 2020-06-22 14:29:45 -0700 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2020-07-13 18:57:17 -0700 |
commit | 957f0c27fc64d2c43a69a6fc5ff7c6f5f81fab2a (patch) | |
tree | bcdbd7a644901c1465f76f2298650aee9a6a77e1 | |
parent | a707466c0b919e686aa54814182bd4559fccaa0d (diff) | |
download | ansible-957f0c27fc64d2c43a69a6fc5ff7c6f5f81fab2a.tar.gz |
[stable-2.10] Fix boilerplate in setup.py and lib/ansible/ dir..
(cherry picked from commit 234994fc075222f28943313024c7df5d7010bc37)
Co-authored-by: Matt Clay <matt@mystile.com>
28 files changed, 65 insertions, 53 deletions
diff --git a/changelogs/fragments/ansible-boilerplate.yml b/changelogs/fragments/ansible-boilerplate.yml new file mode 100644 index 0000000000..7878041134 --- /dev/null +++ b/changelogs/fragments/ansible-boilerplate.yml @@ -0,0 +1,2 @@ +minor_changes: + - Add standard Python 2/3 compatibility boilerplate to setup script, module_utils and docs_fragments which were missing them. diff --git a/lib/ansible/module_utils/_text.py b/lib/ansible/module_utils/_text.py index 373976ce2d..6cd77217eb 100644 --- a/lib/ansible/module_utils/_text.py +++ b/lib/ansible/module_utils/_text.py @@ -1,5 +1,7 @@ # Copyright (c), Toshio Kuratomi <tkuratomi@ansible.com> 2016 # Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type """ .. warn:: Use ansible.module_utils.common.text.converters instead. diff --git a/lib/ansible/module_utils/api.py b/lib/ansible/module_utils/api.py index 781518591f..ca1d978f8f 100644 --- a/lib/ansible/module_utils/api.py +++ b/lib/ansible/module_utils/api.py @@ -41,6 +41,9 @@ The 'api' module provides the following common argument specs: - retries: number of attempts - retry_pause: delay between attempts in seconds """ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import time diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 5b896cf422..b160cecce0 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -3,6 +3,7 @@ # Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) from __future__ import absolute_import, division, print_function +__metaclass__ = type FILE_ATTRIBUTES = { 'A': 'noatime', diff --git a/lib/ansible/module_utils/common/network.py b/lib/ansible/module_utils/common/network.py index cf79db511e..9e1c1ab78b 100644 --- a/lib/ansible/module_utils/common/network.py +++ b/lib/ansible/module_utils/common/network.py @@ -3,6 +3,9 @@ # General networking tools that may be used by all modules +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import re from struct import pack from socket import inet_ntoa diff --git a/lib/ansible/module_utils/connection.py b/lib/ansible/module_utils/connection.py index 40e5cd22fc..a76fdb6bcc 100644 --- a/lib/ansible/module_utils/connection.py +++ b/lib/ansible/module_utils/connection.py @@ -26,6 +26,9 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import hashlib import json diff --git a/lib/ansible/module_utils/facts/sysctl.py b/lib/ansible/module_utils/facts/sysctl.py index 2b2ca43b5b..4c82dc2287 100644 --- a/lib/ansible/module_utils/facts/sysctl.py +++ b/lib/ansible/module_utils/facts/sysctl.py @@ -13,6 +13,9 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import re diff --git a/lib/ansible/module_utils/facts/utils.py b/lib/ansible/module_utils/facts/utils.py index ca67098fe6..9fd00afd49 100644 --- a/lib/ansible/module_utils/facts/utils.py +++ b/lib/ansible/module_utils/facts/utils.py @@ -13,6 +13,9 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os diff --git a/lib/ansible/module_utils/json_utils.py b/lib/ansible/module_utils/json_utils.py index 571fe5b020..d5639fa3f8 100644 --- a/lib/ansible/module_utils/json_utils.py +++ b/lib/ansible/module_utils/json_utils.py @@ -24,6 +24,9 @@ # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import json diff --git a/lib/ansible/module_utils/parsing/convert_bool.py b/lib/ansible/module_utils/parsing/convert_bool.py index e0516efd86..7eea875f79 100644 --- a/lib/ansible/module_utils/parsing/convert_bool.py +++ b/lib/ansible/module_utils/parsing/convert_bool.py @@ -1,6 +1,9 @@ # Copyright: 2017, Ansible Project # Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause ) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + from ansible.module_utils.six import binary_type, text_type from ansible.module_utils._text import to_text diff --git a/lib/ansible/module_utils/pycompat24.py b/lib/ansible/module_utils/pycompat24.py index 70d0c38eeb..0c050dffad 100644 --- a/lib/ansible/module_utils/pycompat24.py +++ b/lib/ansible/module_utils/pycompat24.py @@ -26,6 +26,9 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import sys diff --git a/lib/ansible/module_utils/service.py b/lib/ansible/module_utils/service.py index 3e57b0217b..7369bd786f 100644 --- a/lib/ansible/module_utils/service.py +++ b/lib/ansible/module_utils/service.py @@ -26,6 +26,9 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import glob import os import pickle diff --git a/lib/ansible/module_utils/splitter.py b/lib/ansible/module_utils/splitter.py index 09605eda05..c170b1cf7c 100644 --- a/lib/ansible/module_utils/splitter.py +++ b/lib/ansible/module_utils/splitter.py @@ -26,6 +26,9 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + def _get_quote_state(token, quote_char): ''' diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index a239da411f..2502df092b 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -32,6 +32,9 @@ for users making use of a module. If possible, avoid third party libraries by us this code instead. ''' +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import atexit import base64 import email.mime.multipart diff --git a/lib/ansible/module_utils/yumdnf.py b/lib/ansible/module_utils/yumdnf.py index 47539bf3bd..0d715bfca0 100644 --- a/lib/ansible/module_utils/yumdnf.py +++ b/lib/ansible/module_utils/yumdnf.py @@ -9,6 +9,9 @@ # - Abhijeet Kasurde (@Akasurde) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import time import glob diff --git a/lib/ansible/plugins/doc_fragments/backup.py b/lib/ansible/plugins/doc_fragments/backup.py index 5d46528f26..d2e76dc192 100644 --- a/lib/ansible/plugins/doc_fragments/backup.py +++ b/lib/ansible/plugins/doc_fragments/backup.py @@ -2,6 +2,8 @@ # Copyright: (c) 2015, Ansible, Inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/constructed.py b/lib/ansible/plugins/doc_fragments/constructed.py index c14e5739d2..f2788da0b0 100644 --- a/lib/ansible/plugins/doc_fragments/constructed.py +++ b/lib/ansible/plugins/doc_fragments/constructed.py @@ -2,6 +2,8 @@ # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/decrypt.py b/lib/ansible/plugins/doc_fragments/decrypt.py index f9b3e42ddb..ea7cf59bc3 100644 --- a/lib/ansible/plugins/doc_fragments/decrypt.py +++ b/lib/ansible/plugins/doc_fragments/decrypt.py @@ -2,6 +2,8 @@ # Copyright: (c) 2017, Brian Coca <bcoca@redhat.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/default_callback.py b/lib/ansible/plugins/doc_fragments/default_callback.py index c426cc11c1..8093694a65 100644 --- a/lib/ansible/plugins/doc_fragments/default_callback.py +++ b/lib/ansible/plugins/doc_fragments/default_callback.py @@ -2,6 +2,8 @@ # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/files.py b/lib/ansible/plugins/doc_fragments/files.py index 766b933a40..ed1d9b5006 100644 --- a/lib/ansible/plugins/doc_fragments/files.py +++ b/lib/ansible/plugins/doc_fragments/files.py @@ -2,6 +2,8 @@ # Copyright: (c) 2014, Matt Martz <matt@sivel.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/inventory_cache.py b/lib/ansible/plugins/doc_fragments/inventory_cache.py index 9eefc23d45..342be33427 100644 --- a/lib/ansible/plugins/doc_fragments/inventory_cache.py +++ b/lib/ansible/plugins/doc_fragments/inventory_cache.py @@ -2,6 +2,8 @@ # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/return_common.py b/lib/ansible/plugins/doc_fragments/return_common.py index 6f3866ba5c..6f54288050 100644 --- a/lib/ansible/plugins/doc_fragments/return_common.py +++ b/lib/ansible/plugins/doc_fragments/return_common.py @@ -2,6 +2,8 @@ # Copyright: (c) 2016, Ansible, Inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/shell_common.py b/lib/ansible/plugins/doc_fragments/shell_common.py index a80e7f7147..7ba4049ca6 100644 --- a/lib/ansible/plugins/doc_fragments/shell_common.py +++ b/lib/ansible/plugins/doc_fragments/shell_common.py @@ -1,5 +1,7 @@ # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/shell_windows.py b/lib/ansible/plugins/doc_fragments/shell_windows.py index 66c9603e7f..d6d4d7c59c 100644 --- a/lib/ansible/plugins/doc_fragments/shell_windows.py +++ b/lib/ansible/plugins/doc_fragments/shell_windows.py @@ -1,5 +1,7 @@ # Copyright (c) 2019 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/url.py b/lib/ansible/plugins/doc_fragments/url.py index d6fdcc384d..ddb8e4d114 100644 --- a/lib/ansible/plugins/doc_fragments/url.py +++ b/lib/ansible/plugins/doc_fragments/url.py @@ -2,6 +2,8 @@ # Copyright: (c) 2018, John Barker <gundalow@redhat.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): diff --git a/lib/ansible/plugins/doc_fragments/validate.py b/lib/ansible/plugins/doc_fragments/validate.py index 24c1aa4c74..99bbe00049 100644 --- a/lib/ansible/plugins/doc_fragments/validate.py +++ b/lib/ansible/plugins/doc_fragments/validate.py @@ -2,6 +2,8 @@ # Copyright: (c) 2015, Ansible, Inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type class ModuleDocFragment(object): @@ -1,5 +1,5 @@ - -from __future__ import print_function +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import json import os diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index 6270b2ceb8..53dafcd136 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -63,18 +63,9 @@ lib/ansible/executor/powershell/async_wrapper.ps1 pslint:PSCustomUseLiteralPath lib/ansible/executor/powershell/exec_wrapper.ps1 pslint:PSCustomUseLiteralPath lib/ansible/executor/task_queue_manager.py pylint:blacklisted-name lib/ansible/galaxy/collection.py compile-2.6!skip # 'ansible-galaxy collection' requires 2.7+ -lib/ansible/module_utils/_text.py future-import-boilerplate -lib/ansible/module_utils/_text.py metaclass-boilerplate -lib/ansible/module_utils/api.py future-import-boilerplate -lib/ansible/module_utils/api.py metaclass-boilerplate -lib/ansible/module_utils/basic.py metaclass-boilerplate -lib/ansible/module_utils/common/network.py future-import-boilerplate -lib/ansible/module_utils/common/network.py metaclass-boilerplate lib/ansible/module_utils/compat/_selectors2.py future-import-boilerplate # ignore bundled lib/ansible/module_utils/compat/_selectors2.py metaclass-boilerplate # ignore bundled lib/ansible/module_utils/compat/_selectors2.py pylint:blacklisted-name -lib/ansible/module_utils/connection.py future-import-boilerplate -lib/ansible/module_utils/connection.py metaclass-boilerplate lib/ansible/module_utils/distro/__init__.py empty-init # breaks namespacing, bundled, do not override lib/ansible/module_utils/distro/_distro.py future-import-boilerplate # ignore bundled lib/ansible/module_utils/distro/_distro.py metaclass-boilerplate # ignore bundled @@ -82,15 +73,7 @@ lib/ansible/module_utils/distro/_distro.py no-assert lib/ansible/module_utils/distro/_distro.py pep8!skip # bundled code we don't want to modify lib/ansible/module_utils/facts/__init__.py empty-init # breaks namespacing, deprecate and eventually remove lib/ansible/module_utils/facts/network/linux.py pylint:blacklisted-name -lib/ansible/module_utils/facts/sysctl.py future-import-boilerplate -lib/ansible/module_utils/facts/sysctl.py metaclass-boilerplate lib/ansible/module_utils/facts/system/distribution.py pylint:ansible-bad-function -lib/ansible/module_utils/facts/utils.py future-import-boilerplate -lib/ansible/module_utils/facts/utils.py metaclass-boilerplate -lib/ansible/module_utils/json_utils.py future-import-boilerplate -lib/ansible/module_utils/json_utils.py metaclass-boilerplate -lib/ansible/module_utils/parsing/convert_bool.py future-import-boilerplate -lib/ansible/module_utils/parsing/convert_bool.py metaclass-boilerplate lib/ansible/module_utils/powershell/Ansible.ModuleUtils.ArgvParser.psm1 pslint:PSUseApprovedVerbs lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CommandUtil.psm1 pslint:PSProvideCommentHelp # need to agree on best format for comment location lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CommandUtil.psm1 pslint:PSUseApprovedVerbs @@ -99,11 +82,7 @@ lib/ansible/module_utils/powershell/Ansible.ModuleUtils.FileUtil.psm1 pslint:PSP lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 pslint:PSCustomUseLiteralPath lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 pslint:PSUseApprovedVerbs lib/ansible/module_utils/powershell/Ansible.ModuleUtils.LinkUtil.psm1 pslint:PSUseApprovedVerbs -lib/ansible/module_utils/pycompat24.py future-import-boilerplate -lib/ansible/module_utils/pycompat24.py metaclass-boilerplate lib/ansible/module_utils/pycompat24.py no-get-exception -lib/ansible/module_utils/service.py future-import-boilerplate -lib/ansible/module_utils/service.py metaclass-boilerplate lib/ansible/module_utils/six/__init__.py empty-init # breaks namespacing, bundled, do not override lib/ansible/module_utils/six/__init__.py future-import-boilerplate # ignore bundled lib/ansible/module_utils/six/__init__.py metaclass-boilerplate # ignore bundled @@ -112,14 +91,8 @@ lib/ansible/module_utils/six/__init__.py no-dict-iteritems lib/ansible/module_utils/six/__init__.py no-dict-iterkeys lib/ansible/module_utils/six/__init__.py no-dict-itervalues lib/ansible/module_utils/six/__init__.py replace-urlopen -lib/ansible/module_utils/splitter.py future-import-boilerplate -lib/ansible/module_utils/splitter.py metaclass-boilerplate -lib/ansible/module_utils/urls.py future-import-boilerplate -lib/ansible/module_utils/urls.py metaclass-boilerplate lib/ansible/module_utils/urls.py pylint:blacklisted-name lib/ansible/module_utils/urls.py replace-urlopen -lib/ansible/module_utils/yumdnf.py future-import-boilerplate -lib/ansible/module_utils/yumdnf.py metaclass-boilerplate lib/ansible/modules/command.py validate-modules:doc-missing-type lib/ansible/modules/command.py validate-modules:nonexistent-parameter-documented lib/ansible/modules/command.py validate-modules:parameter-list-no-elements @@ -230,34 +203,10 @@ lib/ansible/playbook/helpers.py pylint:blacklisted-name lib/ansible/playbook/role/__init__.py pylint:blacklisted-name lib/ansible/plugins/action/normal.py action-plugin-docs # default action plugin for modules without a dedicated action plugin lib/ansible/plugins/cache/base.py ansible-doc!skip # not a plugin, but a stub for backwards compatibility -lib/ansible/plugins/doc_fragments/backup.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/backup.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/constructed.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/constructed.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/decrypt.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/decrypt.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/default_callback.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/default_callback.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/files.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/files.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/inventory_cache.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/inventory_cache.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/return_common.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/return_common.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/shell_common.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/shell_common.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/shell_windows.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/shell_windows.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/url.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/url.py metaclass-boilerplate -lib/ansible/plugins/doc_fragments/validate.py future-import-boilerplate -lib/ansible/plugins/doc_fragments/validate.py metaclass-boilerplate lib/ansible/plugins/lookup/sequence.py pylint:blacklisted-name lib/ansible/plugins/strategy/__init__.py pylint:blacklisted-name lib/ansible/plugins/strategy/linear.py pylint:blacklisted-name lib/ansible/vars/hostvars.py pylint:blacklisted-name -setup.py future-import-boilerplate -setup.py metaclass-boilerplate test/integration/targets/ansible-runner/files/adhoc_example1.py future-import-boilerplate test/integration/targets/ansible-runner/files/adhoc_example1.py metaclass-boilerplate test/integration/targets/ansible-runner/files/playbook_example1.py future-import-boilerplate |