Add typing to module_utils.compat. (#77197)

pull/77198/head
Matt Clay 3 years ago committed by GitHub
parent 5a1b891917
commit e314f4e666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- Added ``module_utils.compat.typing`` to facilitate type-hinting on all supported Python versions.

@ -9,14 +9,9 @@ preferring the YAML compiled C extensions to reduce duplicated code.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import types
from functools import partial as _partial
try:
import typing as t
except ImportError:
t = None # type: types.ModuleType | None # type: ignore[no-redef]
import ansible.module_utils.compat.typing as t
HAS_LIBYAML = False
try:

@ -0,0 +1,15 @@
"""Compatibility layer for the `typing` module, providing all Python versions access to the newest type-hinting features."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
# pylint: disable=wildcard-import,unused-wildcard-import
try:
from typing_extensions import *
except ImportError:
pass
try:
from typing import * # type: ignore[misc]
except ImportError:
pass

@ -28,12 +28,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import types
try:
import typing as t
except ImportError:
t = None # type: types.ModuleType | None # type: ignore[no-redef]
import ansible.module_utils.compat.typing as t
from ansible.module_utils.facts.collector import BaseFactCollector

@ -70,12 +70,8 @@ import os
import platform
import socket
import traceback
import types
try:
import typing as t
except ImportError:
t = None # type: types.ModuleType | None # type: ignore[no-redef]
import ansible.module_utils.compat.typing as t
from ansible.module_utils.basic import (
AnsibleModule,

Loading…
Cancel
Save