typing: fix beets.dbcore.query

This commit is contained in:
Šarūnas Nejus
2026-07-06 15:22:12 +01:00
parent b1701c2e12
commit b31c3bf9d4

View File

@@ -170,7 +170,7 @@ class FieldQuery(Query, Generic[P]):
def __eq__(self, other: object) -> bool:
return (
super().__eq__(other)
type(self) is type(other)
and self.field_name == other.field_name
and self.pattern == other.pattern
)
@@ -569,7 +569,7 @@ class CollectionQuery(Query):
return f"{self.__class__.__name__}({self.subqueries!r})"
def __eq__(self, other: object) -> bool:
return super().__eq__(other) and self.subqueries == other.subqueries
return type(self) is type(other) and self.subqueries == other.subqueries
def __hash__(self) -> int:
"""Since subqueries are mutable, this object should not be hashable.
@@ -640,7 +640,7 @@ class NotQuery(Query):
return f"{self.__class__.__name__}({self.subquery!r})"
def __eq__(self, other: object) -> bool:
return super().__eq__(other) and self.subquery == other.subquery
return isinstance(other, NotQuery) and self.subquery == other.subquery
def __hash__(self) -> int:
return hash(("not", hash(self.subquery)))
@@ -920,7 +920,7 @@ class SingletonQuery(FieldQuery[str]):
and singleton:false, singleton:0 are handled consistently.
"""
def __new__(
def __new__( # type: ignore[misc]
cls, field: str, value: str, *args: Any, **kwargs: Any
) -> Query:
query = NoneQuery("album_id")