unitxt.deprecation_utils moduleΒΆ
- exception unitxt.deprecation_utils.DeprecationErrorΒΆ
Bases:
Exception
Custom 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, msg=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.
msg (str, optional) β Additional message regarding the deprecation reason or alternatives.
- Returns:
A decorator that can be applied to functions or class methods.
- Return type:
callable