Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions news/dep-msg-helper.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Add ``deprecation_message`` helper for printing consistent deprecation messages.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
25 changes: 25 additions & 0 deletions src/diffpy/utils/_deprecator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,28 @@ def wrapper(*args, **kwargs):
)

return decorator


def deprecation_message(base, old_name, new_name, removal_version):
"""Generate a deprecation message.

Parameters
----------
base : str
The base module or class where the deprecated item resides.
old_name : str
The name of the deprecated item.
new_name : str
The name of the new item to use.
removal_version : str
The version when the deprecated item will be removed.

Returns
-------
str
A formatted deprecation message.
"""
return (
f"'{base}.{old_name}' is deprecated and will be removed in "
f"version {removal_version}. Please use '{base}.{new_name}' instead."
)
Loading