pygsti.tools.legacytools
Functions related deprecating other functions
Module Contents
Functions
|
Formats and prints a deprecation warning message. |
|
Decorator for deprecating a function. |
|
Utility to deprecate imports from a module. |
- pygsti.tools.legacytools.warn_deprecated(name, replacement=None)
Formats and prints a deprecation warning message.
Parameters
- namestr
The name of the function that is now deprecated.
- replacementstr, optional
the name of the function that should replace it.
Returns
None
- pygsti.tools.legacytools.deprecate(replacement=None)
Decorator for deprecating a function.
Parameters
- replacementstr, optional
the name of the function that should replace it.
Returns
function
- pygsti.tools.legacytools.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_namestr
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_msgstr
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.
Returns
None