mirror of
https://github.com/beetbox/beets.git
synced 2026-02-27 01:32:30 +01:00
Handle DelimitedString fields as native lists in edit plugin
Treat DelimitedString as a safe YAML-editable type in the edit plugin, allowing multi-valued fields to be edited as native lists.
This commit is contained in:
parent
4699958f25
commit
edfe00516f
3 changed files with 13 additions and 3 deletions
|
|
@ -66,6 +66,8 @@ class Type(ABC, Generic[T, N]):
|
|||
"""The `Query` subclass to be used when querying the field.
|
||||
"""
|
||||
|
||||
# For sequence-like types, keep ``model_type`` unsubscripted as it's used
|
||||
# for ``isinstance`` checks. Use ``list`` instead of ``list[str]``
|
||||
model_type: type[T]
|
||||
"""The Python type that is used to represent the value in the model.
|
||||
|
||||
|
|
@ -287,7 +289,7 @@ class String(BaseString[str, Any]):
|
|||
model_type = str
|
||||
|
||||
|
||||
class DelimitedString(BaseString[list[str], list[str]]):
|
||||
class DelimitedString(BaseString[list, list]): # type: ignore[type-arg]
|
||||
r"""A list of Unicode strings, represented in-database by a single string
|
||||
containing delimiter-separated values.
|
||||
|
||||
|
|
@ -297,7 +299,7 @@ class DelimitedString(BaseString[list[str], list[str]]):
|
|||
as it contains a backslash character.
|
||||
"""
|
||||
|
||||
model_type = list[str]
|
||||
model_type = list
|
||||
fmt_delimiter = "; "
|
||||
|
||||
def __init__(self, db_delimiter: str):
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@ from beets.util import PromptChoice
|
|||
|
||||
# These "safe" types can avoid the format/parse cycle that most fields go
|
||||
# through: they are safe to edit with native YAML types.
|
||||
SAFE_TYPES = (types.BaseFloat, types.BaseInteger, types.Boolean)
|
||||
SAFE_TYPES = (
|
||||
types.BaseFloat,
|
||||
types.BaseInteger,
|
||||
types.Boolean,
|
||||
types.DelimitedString,
|
||||
)
|
||||
|
||||
|
||||
class ParseError(Exception):
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ Other changes
|
|||
Previously, ``\␀`` was used as a separator. This applies to fields such as
|
||||
``artists``, ``albumtypes`` etc.
|
||||
- Improve highlighting of multi-valued fields changes.
|
||||
- :doc:`plugins/edit`: Editing multi-valued fields now behaves more naturally,
|
||||
with list values handled directly to make metadata edits smoother and more
|
||||
predictable.
|
||||
|
||||
2.6.2 (February 22, 2026)
|
||||
-------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue