#!/usr/bin/env python# -*- coding: utf-8 -*--# Copyright (c) 2021, 2023 Oracle and/or its affiliates.# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/importwarningsfromenumimportEnumfromfunctoolsimportwraps
[docs]classNotSupportedError(Exception):# pragma: no coverpass
[docs]defdeprecated(deprecated_in:str=None,removed_in:str=None,details:str=None,target_type:str=None,raise_error:bool=False,):"""This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used. Parameters ---------- deprecated_in: `str` Version of ADS where this function deprecated. removed_in: `str` Future version where this function will be removed. details: `str` More information to be shown. """defdecorator(target):@wraps(target)defwrapper(*args,**kwargs):iftarget.__name__=="__init__":_target_type=target_typeorTARGET_TYPE.CLASS.valuetarget_name=target.__qualname__.split(".")[0]else:_target_type=target_typeorTARGET_TYPE.METHOD.valuetarget_name=target.__name__ifdeprecated_in:msg=(f"{_target_type}{target_name} is "f"deprecated in {deprecated_in} and will be "f"removed in {removed_inifremoved_inelse'a future release'}."f"{''ifnotdetailselse' '+details}")else:msg=detailsifraise_error:raiseNotSupportedError(msg)else:warnings.warn(msg,DeprecationWarning,stacklevel=2)returntarget(*args,**kwargs)returnwrapperreturndecorator