trulens.core.utils.deprecation¶
trulens.core.utils.deprecation
¶
Utilities for handling deprecation.
Functions¶
module_getattr_override
¶
Override module's __getattr__
to issue a deprecation errors when
looking up attributes.
This expects deprecated names to be prefixed with DEP_
followed by their
original pre-deprecation name.
Example
# issue module import warning:
package_dep_warn()
# define temporary implementations of to-be-deprecated attributes:
something = ... actual working implementation or alias
# define deprecated attribute with None/any value but name with "DEP_"
# prefix:
DEP_something = None
# issue module deprecation warning and override __getattr__ to issue
# deprecation errors for the above:
module_getattr_override()
Also issues a deprecation warning for the module itself. This will be used in the next deprecation stage for throwing errors after deprecation errors.
is_deprecated
¶
is_deprecated(obj: Any)
Check if object is deprecated.
Presently only supports values created by deprecated_str
.
deprecated_property
¶
deprecated_property(message: str)
Decorator for deprecated attributes defined as properties.
packages_dep_warn
¶
Issue a deprecation warning for a backwards-compatibility modules.
This is specifically for the trulens_eval -> trulens module renaming and
reorganization. If message
is given, that is included first in the
deprecation warning.
has_deprecated
¶
Check if a function or class has been deprecated.
has_moved
¶
Check if a function or class has been moved.
staticmethod_renamed
¶
staticmethod_renamed(new_name: str)
Issue a warning upon static method call that has been renamed or moved.
Issues the warning only once.
method_renamed
¶
method_renamed(new_name: str)
Issue a warning upon method call that has been renamed or moved.
Issues the warning only once.
function_moved
¶
Issue a warning upon function call that has been moved to a new location.
Issues the warning only once. The given callable must have a name, so it cannot be a lambda.
class_moved
¶
Issue a warning upon class instantiation that has been moved to a new location.
Issues the warning only once.
moved
¶
moved(
globals_dict: Dict[str, Any],
old: Optional[str] = None,
new: Optional[str] = None,
names: Optional[Iterable[str]] = None,
)
Replace all classes or function in the given dictionary with ones that issue a deprecation warning upon initialization or invocation.
You can use this with module globals_dict=globals()
and names=__all__
to
deprecate all exposed module members.
PARAMETER | DESCRIPTION |
---|---|
globals_dict
|
The dictionary to update. See globals. |
old
|
The old location of the classes. |
new
|
The new location of the classes. |
names
|
The names of the classes or functions to update. If None, all classes and functions are updated. |