Skip to content

Commit

Permalink
Require from __future__ import annotations (ansible#81902)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclay authored Oct 4, 2023
1 parent 921efce commit 9f899f9
Show file tree
Hide file tree
Showing 1,151 changed files with 1,193 additions and 2,426 deletions.
3 changes: 1 addition & 2 deletions .azure-pipelines/scripts/combine-coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
It is up to pipeline authors to avoid name collisions when deviating from the recommended format.
"""

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import os
import re
Expand Down
1 change: 1 addition & 0 deletions .azure-pipelines/scripts/publish-codecov.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Multiple coverage files from multiple languages are accepted and aggregated after upload.
Python coverage, as well as PowerShell and Python stubs can all be uploaded.
"""
from __future__ import annotations

import argparse
import dataclasses
Expand Down
3 changes: 1 addition & 2 deletions .azure-pipelines/scripts/time-command.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python
"""Prepends a relative timestamp to each input line from stdin and writes it to stdout."""

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import sys
import time
Expand Down
3 changes: 1 addition & 2 deletions hacking/azp/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
"""CLI tool for downloading results from Azure Pipelines CI runs."""

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# noinspection PyCompatibility
import argparse
Expand Down
3 changes: 1 addition & 2 deletions hacking/azp/get_recent_coverage_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
# 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
from __future__ import annotations

from ansible.utils.color import stringc
import requests
Expand Down
3 changes: 1 addition & 2 deletions hacking/azp/incidental.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
"""CLI tool for reporting on incidental test coverage."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# noinspection PyCompatibility
import argparse
Expand Down
3 changes: 1 addition & 2 deletions hacking/azp/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

"""CLI tool for starting new CI runs."""

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# noinspection PyCompatibility
import argparse
Expand Down
4 changes: 1 addition & 3 deletions hacking/backport/backport_of_line_adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

from github.PullRequest import PullRequest
from github import Github
Expand Down
3 changes: 1 addition & 2 deletions hacking/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# PYTHON_ARGCOMPLETE_OK
"""A tool to aggregate data about Ansible source and testing into a sqlite DB for reporting."""

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import argparse
import json
Expand Down
3 changes: 1 addition & 2 deletions hacking/return_skeleton_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
# You will likely want to adjust this to remove sensitive data or
# ensure the `returns` value is correct, and to write a useful description

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

from collections import OrderedDict
import json
Expand Down
3 changes: 1 addition & 2 deletions hacking/test-module.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
# ./hacking/test-module.py -m lib/ansible/modules/lineinfile.py -a "dest=/etc/exports line='/srv/home hostname1(rw,sync)'" --check
# ./hacking/test-module.py -m lib/ansible/modules/command.py -a "echo hello" -n -o "test_hello"

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import glob
import optparse
Expand Down
3 changes: 1 addition & 2 deletions hacking/tests/gen_distribution_version_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
This assumes a working ansible version in the path.
"""

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import json
import os.path
Expand Down
4 changes: 1 addition & 3 deletions lib/ansible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# make vendored top-level modules accessible EARLY
import ansible._vendor
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright: (c) 2021, Matt Martz <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations

import argparse
import importlib
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/_vendor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# (c) 2020 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
from __future__ import annotations

import os
import pkgutil
Expand Down
4 changes: 1 addition & 3 deletions lib/ansible/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import locale
import os
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/adhoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/arguments/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright: (c) 2018, 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
from __future__ import annotations
3 changes: 1 addition & 2 deletions lib/ansible/cli/arguments/option_helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright: (c) 2018, 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
from __future__ import annotations

import copy
import operator
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
5 changes: 1 addition & 4 deletions lib/ansible/cli/scripts/ansible_connection_cli_stub.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python
# 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

from __future__ import annotations

import fcntl
import hashlib
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/cli/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# PYTHON_ARGCOMPLETE_OK

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/collections/list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# (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 annotations

from ansible.errors import AnsibleError
from ansible.cli.galaxy import with_collection_artifacts_manager
Expand Down
5 changes: 1 addition & 4 deletions lib/ansible/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

'''
Compat library for ansible. This contains compatibility definitions for older python
When we need to import a module differently depending on python version, do it
here. Then in the code we can simply import from compat in order to get what we want.
'''
from __future__ import annotations
3 changes: 1 addition & 2 deletions lib/ansible/compat/importlib_resources.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright: Contributors to the 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
from __future__ import annotations

import sys

Expand Down
6 changes: 2 additions & 4 deletions lib/ansible/compat/selectors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

# NOT_BUNDLED

'''
Expand All @@ -27,6 +23,8 @@
Implementation previously resided here - maintaining this file after the
move to ansible.module_utils for code backwards compatibility.
'''
from __future__ import annotations

import sys
from ansible.module_utils.compat import selectors
sys.modules['ansible.compat.selectors'] = selectors
3 changes: 1 addition & 2 deletions lib/ansible/config/manager.py
Original file line number Diff line number Diff line change
@@ -1,8 +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
from __future__ import annotations

import atexit
import configparser
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,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
from __future__ import annotations

import re

Expand Down
5 changes: 1 addition & 4 deletions lib/ansible/context.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Copyright: (c) 2018, Toshio Kuratomi <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

"""
Context of the running Ansible.
Expand All @@ -14,6 +10,7 @@
These APIs are still in flux so do not use them unless you are willing to update them with every Ansible release
"""
from __future__ import annotations

from collections.abc import Mapping, Set

Expand Down
4 changes: 1 addition & 3 deletions lib/ansible/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import re
import traceback
Expand Down
4 changes: 1 addition & 3 deletions lib/ansible/errors/yaml_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

__all__ = [
'YAML_SYNTAX_ERROR',
Expand Down
4 changes: 1 addition & 3 deletions lib/ansible/executor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations
Loading

0 comments on commit 9f899f9

Please sign in to comment.