mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 04:39:11 +00:00
feat: don't enforce dumpster location; allow in-place deprecations; diverge from frappe practice
This commit is contained in:
@@ -15,8 +15,6 @@ Remember, deprecated doesn't mean useless - it just means these functions are en
|
|||||||
Enjoy your stay in the Deprecation Dumpster, where every function gets a second chance to shine (or at least, to not break everything).
|
Enjoy your stay in the Deprecation Dumpster, where every function gets a second chance to shine (or at least, to not break everything).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import inspect
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@@ -77,20 +75,6 @@ def deprecated(original: str, marked: str, graduation: str, msg: str, stacklevel
|
|||||||
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
# Get the filename of the caller
|
# Get the filename of the caller
|
||||||
frame = inspect.currentframe()
|
|
||||||
caller_filepath = frame.f_back.f_code.co_filename
|
|
||||||
if os.path.basename(caller_filepath) != "deprecation_dumpster.py":
|
|
||||||
raise RuntimeError(
|
|
||||||
colorize("The deprecated function ", Color.YELLOW)
|
|
||||||
+ colorize(func.__name__, Color.CYAN)
|
|
||||||
+ colorize(" can only be called from ", Color.YELLOW)
|
|
||||||
+ colorize("erpnext/deprecation_dumpster.py\n", Color.CYAN)
|
|
||||||
+ colorize("Move the entire function there and import it back via adding\n ", Color.YELLOW)
|
|
||||||
+ colorize(f"from erpnext.deprecation_dumpster import {func.__name__}\n", Color.CYAN)
|
|
||||||
+ colorize("to file\n ", Color.YELLOW)
|
|
||||||
+ colorize(caller_filepath, Color.CYAN)
|
|
||||||
)
|
|
||||||
|
|
||||||
func.__name__ = original
|
func.__name__ = original
|
||||||
wrapper = _deprecated(
|
wrapper = _deprecated(
|
||||||
colorize(f"It was marked on {marked} for removal from {graduation} with note: ", Color.RED)
|
colorize(f"It was marked on {marked} for removal from {graduation} with note: ", Color.RED)
|
||||||
|
|||||||
Reference in New Issue
Block a user