Skip to content

Commit 5e6be0d

Browse files
committed
Use short-circuit evaluation in AndQuery and OrQuery (fix #4145)
1 parent f3552f0 commit 5e6be0d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

beets/dbcore/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def clause(self):
443443
return self.clause_with_joiner('and')
444444

445445
def match(self, item):
446-
return all([q.match(item) for q in self.subqueries])
446+
return all(q.match(item) for q in self.subqueries)
447447

448448

449449
class OrQuery(MutableCollectionQuery):
@@ -453,7 +453,7 @@ def clause(self):
453453
return self.clause_with_joiner('or')
454454

455455
def match(self, item):
456-
return any([q.match(item) for q in self.subqueries])
456+
return any(q.match(item) for q in self.subqueries)
457457

458458

459459
class NotQuery(Query):

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ Bug fixes:
7373
* :doc:`/dev/library`: Use slow queries for flexible attributes in aunique.
7474
:bug:`2678` :bug:`3553`
7575

76+
* :doc:`/reference/query`: Use short-circuit evaluation in AndQuery and OrQuery
77+
:bug:`4145`
78+
7679
1.5.0 (August 19, 2021)
7780
-----------------------
7881

0 commit comments

Comments
 (0)