pygsti.tools.legacytools.deprecate_imports#
- deprecate_imports(module_name, replacement_map, warning_msg)#
Utility to deprecate imports from a module.
This works by swapping the underlying module in the import mechanisms with a ModuleType object that overrides attribute lookup to check against the replacement map.
Note that this will slow down module attribute lookup substantially. If you need to deprecate multiple names, DO NOT call this method more than once on a given module! Instead, use the replacement map to batch multiple deprecations into one call. When using this method, plan to remove the deprecated paths altogether sooner rather than later.
- Parameters:
module_name (str) – The fully-qualified name of the module whose names have been deprecated.
replacement_map ({name: function}) – A map of each deprecated name to a factory which will be called with no arguments when importing the name.
warning_msg (str) – A message to be displayed as a warning when importing a deprecated name. Optionally, this may include the format string name, which will be formatted with the deprecated name.
- Return type:
None