schrodinger.utils.deprecation module¶
Deprecation handling
Copyright Schrodinger LLC, All Rights Reserved.
- exception schrodinger.utils.deprecation.DeprecationError¶
Bases:
RuntimeError
Exception indicating API deprecation
- __init__(*args, **kwargs)¶
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- schrodinger.utils.deprecation.raise_deprecation_error(msg: str, to_remove_in: str)¶
Raise a
DeprecationError
unless USE_DEPRECATED feature flag is set, which will issue a DeprecationWarning only.- Parameters
msg – deprecation message to issue
to_remove_in – Schrodinger core suite release version (XXXX-X)
- schrodinger.utils.deprecation.deprecate_module(module_name: str, to_remove_in: str, replacement: Optional[str] = None)¶
Raises a deprecation error (or only prints a warning when USE_DEPRECATED is enabled), indicating to the caller that the import should be removed, and updated to a new module if applicable.
- Parameters
module_name – name of module which is deprecated
to_remove_in – Schrodinger core suite release version (XXXX-X)
replacement – replacement module name
- schrodinger.utils.deprecation.deprecated(func: Callable, to_remove_in: Optional[str] = None, replacement: Optional[Callable] = None, msg: Optional[str] = None, *args, **kwargs)¶
Raises a deprecation error (or only prints a warning when USE_DEPRECATED is enabled), indicating to the caller that the decorated call should be removed, and updated to a new function/method call if applicable.
Note: To deprecate a method in a class for another, use the local name of the new method, e.g.
class MyClass: def newMethod(self): pass @deprecated(to_remove_in="XXXX-X", replacement=newMethod) def oldMethod(self): pass
Note: To deprecate a staticmethod or a classmethod, this decorator should be innermost, e.g.
@staticmethod @deprecated(...) def foo(): pass
See the tests for this module for examples of deprecating functions, methods, classmethods and staticmethods.
(to deprecate a method in a class for another, use the “short name” of the updated method, e.g. “thing2” instead of “X.thing2”)
- Parameters
func – deprecated function/method
to_remove_in – Schrodinger core suite release version (XXXX-X)
replacement – current function/method to use
msg – specific message if default message is not desired
- schrodinger.utils.deprecation.enable_deprecated()¶
Enables deprecated imports/functions within managed context