swallow all exceptions in type annotation support shim imports (#77860)

* swallow all exceptions in type annotation support shim imports

* add changelog
This commit is contained in:
Matt Davis
2022-05-25 14:41:06 -05:00
committed by GitHub
parent e7e1d592a6
commit 813afcbbb4
2 changed files with 7 additions and 2 deletions
@@ -0,0 +1,2 @@
bugfixes:
- prevent type annotation shim failures from causing runtime failures (https://github.com/ansible/ansible/pull/77860)
+5 -2
View File
@@ -4,12 +4,15 @@ __metaclass__ = type
# pylint: disable=wildcard-import,unused-wildcard-import
# catch *all* exceptions to prevent type annotation support module bugs causing runtime failures
# (eg, https://github.com/ansible/ansible/issues/77857)
try:
from typing_extensions import *
except ImportError:
except Exception: # pylint: disable=broad-except
pass
try:
from typing import * # type: ignore[misc]
except ImportError:
except Exception: # pylint: disable=broad-except
pass