mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 00:24:25 +01:00
Add deprecate_for_user function
This commit is contained in:
parent
39288637b9
commit
5a3ecf6842
3 changed files with 19 additions and 10 deletions
|
|
@ -32,7 +32,7 @@ from typing_extensions import ParamSpec
|
|||
import beets
|
||||
from beets import logging
|
||||
from beets.util import unique_list
|
||||
from beets.util.deprecation import deprecate_for_maintainers
|
||||
from beets.util.deprecation import deprecate_for_maintainers, deprecate_for_user
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable, Iterable, Sequence
|
||||
|
|
@ -257,14 +257,14 @@ class BeetsPlugin(metaclass=abc.ABCMeta):
|
|||
):
|
||||
return
|
||||
|
||||
message = (
|
||||
"'source_weight' configuration option is deprecated and will be"
|
||||
" removed in v3.0.0. Use 'data_source_mismatch_penalty' instead"
|
||||
)
|
||||
for source in self.config.root().sources:
|
||||
if "source_weight" in (source.get(self.name) or {}):
|
||||
if source.filename: # user config
|
||||
self._log.warning(message)
|
||||
deprecate_for_user(
|
||||
self._log,
|
||||
f"'{self.name}.source_weight' configuration option",
|
||||
f"'{self.name}.data_source_mismatch_penalty'",
|
||||
)
|
||||
else: # 3rd-party plugin config
|
||||
deprecate_for_maintainers(
|
||||
"'source_weight' configuration option",
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ from __future__ import annotations
|
|||
|
||||
import warnings
|
||||
from importlib import import_module
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from packaging.version import Version
|
||||
|
||||
import beets
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from logging import Logger
|
||||
|
||||
|
||||
def _format_message(old: str, new: str | None = None) -> str:
|
||||
next_major = f"{Version(beets.__version__).major + 1}.0.0"
|
||||
|
|
@ -18,6 +21,10 @@ def _format_message(old: str, new: str | None = None) -> str:
|
|||
return msg
|
||||
|
||||
|
||||
def deprecate_for_user(logger: Logger, old: str, new: str) -> None:
|
||||
logger.warning(_format_message(old, new))
|
||||
|
||||
|
||||
def deprecate_for_maintainers(
|
||||
old: str, new: str | None = None, stacklevel: int = 1
|
||||
) -> None:
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import beets
|
|||
import beets.autotag.hooks
|
||||
from beets import config, plugins, util
|
||||
from beets.metadata_plugins import MetadataSourcePlugin
|
||||
from beets.util.deprecation import deprecate_for_user
|
||||
from beets.util.id_extractors import extract_release_id
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -403,9 +404,10 @@ class MusicBrainzPlugin(MetadataSourcePlugin):
|
|||
self.config["search_limit"] = self.config["match"][
|
||||
"searchlimit"
|
||||
].get()
|
||||
self._log.warning(
|
||||
"'musicbrainz.searchlimit' option is deprecated and will be "
|
||||
"removed in 3.0.0. Use 'musicbrainz.search_limit' instead."
|
||||
deprecate_for_user(
|
||||
self._log,
|
||||
"'musicbrainz.searchlimit' configuration option",
|
||||
"'musicbrainz.search_limit'",
|
||||
)
|
||||
hostname = self.config["host"].as_str()
|
||||
https = self.config["https"].get(bool)
|
||||
|
|
|
|||
Loading…
Reference in a new issue