[SingletonQuery] correct superclass typing

I had misinterpreted the pattern type for this query to be 'NoReturn',
thinking that it accepted no pattern at all (even so, I should have
typed it as 'None').  However, it does accept a pattern, and uses it to
decide whether to select only singletons or none at all.

See <https://github.com/beetbox/beets/pull/5282#discussion_r1633212742>.
This commit is contained in:
Arav K. 2024-06-12 16:02:00 +02:00
parent 549fea14cd
commit c7ca2efbba

View file

@ -23,7 +23,6 @@ import sys
import time
import unicodedata
from functools import cached_property
from typing import NoReturn
from mediafile import MediaFile, UnreadableFileError
@ -50,7 +49,7 @@ log = logging.getLogger("beets")
# Library-specific query types.
class SingletonQuery(dbcore.FieldQuery[NoReturn]):
class SingletonQuery(dbcore.FieldQuery[str]):
"""This query is responsible for the 'singleton' lookup.
It is based on the FieldQuery and constructs a SQL clause
@ -61,7 +60,7 @@ class SingletonQuery(dbcore.FieldQuery[NoReturn]):
and singleton:false, singleton:0 are handled consistently.
"""
def __new__(cls, field, value, *args, **kwargs):
def __new__(cls, field: str, value: str, *args, **kwargs):
query = dbcore.query.NoneQuery("album_id")
if util.str2bool(value):
return query