track already reported deprecated modules (mark's update)
This commit is contained in:
@@ -6,16 +6,24 @@
|
|||||||
|
|
||||||
from typing import Any, Dict
|
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):
|
def _warn_deprecated_access(globals: Dict[str, Any], attr, old: str, new: str):
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
with warnings.catch_warnings():
|
# Only warn once per old->new module pair
|
||||||
warnings.simplefilter("always")
|
module_key = (old, new)
|
||||||
warnings.warn(
|
if module_key not in _warned_modules:
|
||||||
f"Module `pipecat.services.{old}` is deprecated, use `pipecat.services.{new}` instead",
|
with warnings.catch_warnings():
|
||||||
DeprecationWarning,
|
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]
|
return globals[attr]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user