MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / wrapper

Function wrapper

python/paddle/utils/deprecated.py:113–143  ·  view source on GitHub ↗

deprecated warning should be fired in 3 circumstances: 1. current version is develop version, i.e. "0.0.0", because we assume develop version is always the latest version. 2. since version is empty, in this case, API is deprecated in all versions. 3. current versi

(*args: _InputT.args, **kwargs: _InputT.kwargs)

Source from the content-addressed store, hash-verified

111
112 @functools.wraps(func)
113 def wrapper(*args: _InputT.args, **kwargs: _InputT.kwargs) -> _RetT:
114 """deprecated warning should be fired in 3 circumstances:
115 1. current version is develop version, i.e. "0.0.0", because we assume develop version is always the latest version.
116 2. since version is empty, in this case, API is deprecated in all versions.
117 3. current version is newer than since version.
118 """
119
120 if level == 2:
121 raise RuntimeError(
122 f'API "{func.__module__}.{func.__name__}" has been deprecated.'
123 )
124
125 warningmsg = f"\033[93m\nWarning:\n{msg} \033[0m"
126 # ensure ANSI escape sequences print correctly in cmd and powershell
127 if sys.platform.lower() == 'win32':
128 warningmsg = f"\nWarning:\n{msg} "
129
130 v_current = parse_version(paddle.__version__)
131 v_current += [0] * (4 - len(v_current))
132 v_since = parse_version(since)
133 v_since += [0] * (4 - len(v_since))
134 if (
135 paddle.__version__ == "0.0.0"
136 or _since == ""
137 or v_current >= v_since
138 ):
139 warnings.warn(
140 warningmsg, category=VisibleDeprecationWarning, stacklevel=2
141 )
142
143 return func(*args, **kwargs)
144
145 return wrapper
146

Callers

nothing calls this directly

Calls 5

RuntimeErrorClass · 0.85
parse_versionFunction · 0.85
lowerMethod · 0.80
funcFunction · 0.50
warnMethod · 0.45

Tested by

no test coverage detected