Context manager to suppress package and module deprecation warnings when importing them. If ignore is False, this context manager has no effect.
(ignore=True)
| 15 | |
| 16 | @contextlib.contextmanager |
| 17 | def _ignore_deprecated_imports(ignore=True): |
| 18 | """Context manager to suppress package and module deprecation |
| 19 | warnings when importing them. |
| 20 | |
| 21 | If ignore is False, this context manager has no effect. |
| 22 | """ |
| 23 | if ignore: |
| 24 | with warnings.catch_warnings(): |
| 25 | warnings.filterwarnings("ignore", ".+ (module|package)", |
| 26 | DeprecationWarning) |
| 27 | yield |
| 28 | else: |
| 29 | yield |
| 30 | |
| 31 | |
| 32 | def unload(name): |
no outgoing calls
no test coverage detected