Skip to content

Commit cdc091a

Browse files
committed
function for deprecation print message
1 parent a4c07ef commit cdc091a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/diffpy/utils/_deprecator.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,28 @@ def wrapper(*args, **kwargs):
8181
)
8282

8383
return decorator
84+
85+
86+
def deprecation_message(base, old_name, new_name, removal_version):
87+
"""Generate a deprecation message.
88+
89+
Parameters
90+
----------
91+
base : str
92+
The base module or class where the deprecated item resides.
93+
old_name : str
94+
The name of the deprecated item.
95+
new_name : str
96+
The name of the new item to use.
97+
removal_version : str
98+
The version when the deprecated item will be removed.
99+
100+
Returns
101+
-------
102+
str
103+
A formatted deprecation message.
104+
"""
105+
return (
106+
f"'{base}.{old_name}' is deprecated and will be removed in "
107+
f"version {removal_version}. Please use '{base}.{new_name}' instead."
108+
)

0 commit comments

Comments
 (0)