Skip to content

Commit 248f2be

Browse files
committed
Added deprication decorator support
1 parent ba563e6 commit 248f2be

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
3+
# See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
6+
7+
# Note: The code within this file was created in total or in part
8+
# with the use of AI tools.
9+
10+
import warnings
11+
import functools
12+
13+
def _deprecated(reason):
14+
"""
15+
A decorator to mark functions as deprecated.
16+
17+
Args:
18+
reason (str): The reason why the function is deprecated.
19+
20+
Returns:
21+
function: The decorated function that emits a DeprecationWarning when called.
22+
"""
23+
def decorator(func):
24+
@functools.wraps(func)
25+
def wrapper(*args, **kwargs):
26+
warnings.warn(
27+
f"{func.__name__} is deprecated: {reason}",
28+
category=DeprecationWarning,
29+
stacklevel=2
30+
)
31+
return func(*args, **kwargs)
32+
return wrapper
33+
return decorator

0 commit comments

Comments
 (0)