From 94ec5118e685dc80431bc04c1dbd722c8d9d0eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Sun, 30 Mar 2025 07:56:08 -0700 Subject: [PATCH] track already reported deprecated modules (mark's update) --- src/pipecat/services/__init__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pipecat/services/__init__.py b/src/pipecat/services/__init__.py index d79c1793d..a541ecfe7 100644 --- a/src/pipecat/services/__init__.py +++ b/src/pipecat/services/__init__.py @@ -6,16 +6,24 @@ from typing import Any, Dict +# Track which modules we've already warned about +_warned_modules = set() + def _warn_deprecated_access(globals: Dict[str, Any], attr, old: str, new: str): import warnings - with warnings.catch_warnings(): - warnings.simplefilter("always") - warnings.warn( - f"Module `pipecat.services.{old}` is deprecated, use `pipecat.services.{new}` instead", - DeprecationWarning, - ) + # Only warn once per old->new module pair + module_key = (old, new) + if module_key not in _warned_modules: + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + f"Module `pipecat.services.{old}` is deprecated, use `pipecat.services.{new}` instead.", + DeprecationWarning, + stacklevel=3, + ) + _warned_modules.add(module_key) return globals[attr]