Merge pull request #4368 from wisp3rwind/pr_better_mediafile_deprecation_warning

mediafile: Improve deprecation warning
This commit is contained in:
Adrian Sampson 2022-06-12 12:07:11 -04:00 committed by GitHub
commit 0af282b823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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