From c657fb66421f8d97c862f9e6b8d626d19739cf9c Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Sun, 12 Jun 2022 17:56:53 +0200 Subject: [PATCH] mediafile: Improve deprecation warning This is for mediafile what cc8c3529fbf528da8eadadf2ff61389db9adf767 was for confit, cf. https://github.com/beetbox/beets/pull/4263 --- beets/mediafile.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/beets/mediafile.py b/beets/mediafile.py index 82bcc973d..46288a71d 100644 --- a/beets/mediafile.py +++ b/beets/mediafile.py @@ -16,11 +16,18 @@ import mediafile import warnings -warnings.warn("beets.mediafile is deprecated; use mediafile instead") +warnings.warn( + "beets.mediafile is deprecated; use mediafile instead", + # Show the location of the `import mediafile` statement as the warning's + # source, rather than this file, such that the offending module can be + # identified easily. + stacklevel=2, +) # Import everything from the mediafile module into this module. for key, value in mediafile.__dict__.items(): if key not in ['__name__']: globals()[key] = value +# Cleanup namespace. del key, value, warnings, mediafile