Deprecation warning enhancement (#1738)
This commit is contained in:
parent
dd03a277cf
commit
141d1c3aab
@ -36,7 +36,12 @@ def route(
|
|||||||
Returns:
|
Returns:
|
||||||
The decorated function.
|
The decorated function.
|
||||||
"""
|
"""
|
||||||
deprecate("@rx.route is deprecated and is being replaced by @rx.page instead")
|
deprecate(
|
||||||
|
feature_name="@rx.route",
|
||||||
|
deprecation_version="0.2.3",
|
||||||
|
reason="and is being replaced by @rx.page due to enhanced routing features.",
|
||||||
|
removal_version="0.2.8",
|
||||||
|
)
|
||||||
|
|
||||||
return page(
|
return page(
|
||||||
route=route,
|
route=route,
|
||||||
|
@ -102,13 +102,27 @@ def warn(msg: str, **kwargs):
|
|||||||
print(f"[orange1]Warning: {msg}[/orange1]", **kwargs)
|
print(f"[orange1]Warning: {msg}[/orange1]", **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def deprecate(msg: str, **kwargs):
|
# def deprecate(msg: str, **kwargs):
|
||||||
|
def deprecate(
|
||||||
|
feature_name: str,
|
||||||
|
reason: str,
|
||||||
|
deprecation_version: str,
|
||||||
|
removal_version: str,
|
||||||
|
**kwargs,
|
||||||
|
):
|
||||||
"""Print a deprecation warning.
|
"""Print a deprecation warning.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
msg: The deprecation message.
|
feature_name: The feature to deprecate.
|
||||||
|
reason: The reason for deprecation.
|
||||||
|
deprecation_version: The version the feature was deprecated
|
||||||
|
removal_version: The version the deprecated feature will be removed.
|
||||||
kwargs: Keyword arguments to pass to the print function.
|
kwargs: Keyword arguments to pass to the print function.
|
||||||
"""
|
"""
|
||||||
|
msg = (
|
||||||
|
f"{feature_name} has been deprecated in version {deprecation_version} {reason}. It will be completely "
|
||||||
|
f"removed in {removal_version}"
|
||||||
|
)
|
||||||
if LOG_LEVEL <= LogLevel.WARNING:
|
if LOG_LEVEL <= LogLevel.WARNING:
|
||||||
print(f"[yellow]DeprecationWarning: {msg}[/yellow]", **kwargs)
|
print(f"[yellow]DeprecationWarning: {msg}[/yellow]", **kwargs)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user