Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _deregister_post_import_hook(modulename, matcher):
"""
Deregisters post import hooks for a module given the module name and a
matcher function. All hooks matching the matcher function will be removed.
"""
hooks = _post_import_hooks.get(modulename, []) or []
hooks = list(filter(lambda h: not matcher(h), hooks))
# Work around for wrapt since wrapt assumes that if
# _post_import_hooks.get(modulename) is not None then the module must have
# been imported.
if not len(hooks):
hooks = None
_post_import_hooks[modulename] = hooks