1"""Compatibility layer for the `typing` module, providing all Python versions access to the newest type-hinting features."""
2from __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
9try:
10 from typing_extensions import *
11except Exception: # pylint: disable=broad-except
12 pass
13
14try:
15 from typing import * # type: ignore[assignment,no-redef]
16except Exception: # pylint: disable=broad-except
17 pass
18
19
20try:
21 cast # type: ignore[used-before-def]
22except NameError:
23 def cast(typ, val): # type: ignore[no-redef]
24 return val