| 1 |
"""Compatibility layer for the `typing` module, providing all Python versions access to the newest type-hinting features.""" |
| 2 |
from __future__ import annotations |
| 3 |
|
| 4 |
# pylint: disable=wildcard-import,unused-wildcard-import |
| 5 |
|
| 6 |
# catch *all* exceptions to prevent type annotation support module bugs causing runtime failures |
| 7 |
# (eg, https://github.com/ansible/ansible/issues/77857) |
| 8 |
|
| 9 |
TYPE_CHECKING = False |
| 10 |
|
| 11 |
try: |
| 12 |
from typing_extensions import * |
| 13 |
except Exception: # pylint: disable=broad-except |
| 14 |
pass |
| 15 |
|
| 16 |
try: |
| 17 |
from typing import * # type: ignore[assignment,no-redef] |
| 18 |
except Exception: # pylint: disable=broad-except |
| 19 |
pass |
| 20 |
|
| 21 |
|
| 22 |
# this import and patch occur after typing_extensions/typing imports since the presence of those modules affects dataclasses behavior |
| 23 |
from .._internal._patches import _dataclass_annotation_patch |
| 24 |
|
| 25 |
_dataclass_annotation_patch.DataclassesIsTypePatch.patch() |