unitxt.deprecation_utils module¶
- exception unitxt.deprecation_utils.DeprecationError¶
Bases:
ExceptionCustom exception for deprecated versions.
- unitxt.deprecation_utils.compare_versions(version1, version2)¶
Compare two semantic versioning strings and determine their relationship.
Parameters: - version1 (str): The first version string to compare. - version2 (str): The second version string to compare.
Returns: - int: -1 if version1 < version2, 1 if version1 > version2, 0 if equal.
Example: >>> compare_versions(“1.2.0”, “1.2.3”) -1 >>> compare_versions(“1.3.0”, “1.2.8”) 1 >>> compare_versions(“1.0.0”, “1.0.0”) 0
- unitxt.deprecation_utils.depraction_wrapper(obj, version, alt_text)¶
A wrapper function for deprecation handling, issuing warnings or errors based on version comparison.
- Parameters:
obj (callable) – The object to be wrapped, typically a function or class method.
version (str) – The version at which the object becomes deprecated.
alt_text (str) – Additional text to display, usually suggests an alternative.
- Returns:
A wrapped version of the original object that checks for deprecation.
- Return type:
callable
- unitxt.deprecation_utils.deprecation(version, alternative=None)¶
Decorator for marking functions or class methods as deprecated.
- Parameters:
version (str) – The version at which the function or method becomes deprecated.
alternative (str, optional) – Suggested alternative to the deprecated functionality.
- Returns:
A decorator that can be applied to functions or class methods.
- Return type:
callable