Skip to content

Commit 794ec0f

Browse files
committed
Update warn_deprecation to get deprecated and removal versions
1 parent 2287b30 commit 794ec0f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pythainlp/tools/core.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,26 @@
1212
def warn_deprecation(
1313
deprecated_func: str,
1414
replacing_func: str = "",
15-
version: str = "",
15+
deprecated_version: str = "",
16+
removal_version: str = "",
1617
):
1718
"""Warn about the deprecation of a function.
1819
1920
:param str deprecated_func: Name of the deprecated function.
2021
:param str replacing_func: Name of the function to use instead (optional).
21-
:param str version: PyThaiNLP version in which the function will be deprecated (optional).
22+
:param str deprecated_version: PyThaiNLP version in which the function will be deprecated (optional).
23+
:param str removal_version: PyThaiNLP version in which the function will be removed (optional).
2224
"""
23-
if version:
24-
version = f"PyThaiNLP {version}"
25-
else:
26-
version = "a future release"
27-
message = f"The '{deprecated_func}' function is deprecated and will be removed in {version}."
25+
message = f"The '{deprecated_func}' function is deprecated"
26+
if deprecated_version:
27+
message += f" since {deprecated_version}"
28+
if not removal_version:
29+
removal_version = "a future release"
30+
message += f" and will be removed in {removal_version}."
2831
if replacing_func:
2932
message += f" Please use '{replacing_func}' instead."
3033
warnings.warn(message, DeprecationWarning, stacklevel=2)
3134

32-
3335
def safe_print(text: str):
3436
"""Print text to console, handling UnicodeEncodeError.
3537

0 commit comments

Comments
 (0)