Fix deprecation warning

This commit is contained in:
Šarūnas Nejus 2026-02-09 22:28:45 +00:00
parent 6778e58198
commit 2c61176592
No known key found for this signature in database

View file

@ -16,7 +16,6 @@
from __future__ import annotations
import warnings
from copy import deepcopy
from dataclasses import dataclass
from functools import cached_property
@ -25,6 +24,7 @@ from typing import TYPE_CHECKING, Any, TypeVar
from typing_extensions import Self
from beets.util import cached_classproperty
from beets.util.deprecation import deprecate_for_maintainers
if TYPE_CHECKING:
from beets.library import Item
@ -82,24 +82,16 @@ class Info(AttrDict[Any]):
**kwargs,
) -> None:
if genre:
warnings.warn(
"The 'genre' parameter is deprecated. Use 'genres' (list) instead.",
DeprecationWarning,
stacklevel=2,
deprecate_for_maintainers(
"The 'genre' parameter", "'genres' (list)", stacklevel=3
)
if not genres:
for separator in [", ", "; ", " / "]:
if separator in genre:
split_genres = [
g.strip()
for g in genre.split(separator)
if g.strip()
]
if len(split_genres) > 1:
genres = split_genres
break
if not genres:
try:
sep = next(s for s in [", ", "; ", " / "] if s in genre)
except StopIteration:
genres = [genre]
else:
genres = list(map(str.strip, genre.split(sep)))
self.album = album
self.artist = artist