diff --git a/supervision/metrics/detection.py b/supervision/metrics/detection.py index dcc90726..bc393469 100644 --- a/supervision/metrics/detection.py +++ b/supervision/metrics/detection.py @@ -500,7 +500,7 @@ class ConfusionMatrix: "`supervision.metrics.mean_average_precision.MeanAveragePrecision` instead. The " "deprecated implementation provides results that are inconsistent with pycocotools." ) -@dataclass() +@dataclass(frozen=True) class MeanAveragePrecision: """ !!! deprecated "Deprecated" diff --git a/supervision/utils/internal.py b/supervision/utils/internal.py index 242a4172..1cced171 100644 --- a/supervision/utils/internal.py +++ b/supervision/utils/internal.py @@ -114,13 +114,25 @@ def deprecated_parameter( def deprecated(reason: str): - def decorator(func): - @functools.wraps(func) - def wrapper(*args, **kwargs): - warn_deprecated(f"{func.__name__} is deprecated: {reason}") - return func(*args, **kwargs) + def decorator(cls_or_func): + if inspect.isclass(cls_or_func): + original_init = cls_or_func.__init__ - return wrapper + @functools.wraps(original_init) + def new_init(self, *args, **kwargs): + warn_deprecated(f"{cls_or_func.__name__} is deprecated: {reason}") + original_init(self, *args, **kwargs) + + cls_or_func.__init__ = new_init + return cls_or_func + else: + + @functools.wraps(cls_or_func) + def wrapper(*args, **kwargs): + warn_deprecated(f"{cls_or_func.__name__} is deprecated: {reason}") + return cls_or_func(*args, **kwargs) + + return wrapper return decorator