@contextlib.contextmanager
def _ignore_deprecated_imports(ignore=True):
 if ignore:
  with warnings.catch_warnings():
   warnings.filterwarnings('ignore', '.+ (module|package)', DeprecationWarning)
   (yield)
 else:
  (yield)

@ contextlib . contextmanager def _ignore_deprecated_imports ( ignore = True ) : if ignore : with warnings . catch_warnings ( ) : warnings . filterwarnings ( 'ignore' , '.+ (module|package)' , DeprecationWarning ) ( yield ) else : ( yield )
context manager to suppress package and module deprecation warnings when importing them .