Open charliec111 opened 3 months ago
For whoever looks into this in more depth: The issue is with InQuery
(subclassed by PlaylistQuery
), which has pattern type Sequence[AnySQLiteType]
, which is not guaranteed to be hashable depending on the sequence type. Maybe the best solution would be to override __hash__
in InQuery
? It might also be worth exploring if we can use the type checker to verify that concreate pattern types support the hashable protocol?
While at it, InQuery
should probably also override __eq__
in a way that ignores ordering of the pattern type.
Moreover, I don't think the smartplaylist plugin should be hashing the queries in the first place: This happens because they end up being put in a set
. However, at a first glance, the playlist name is a unique key, so rather than set
s, dict
s should be used.
Problem
This arose after updating to 2.0.0 (I had previously been using 1.6.1 from pip, this did not appear. It looks like 2.0 has been out, I must not have updated in a while.). I've confirmed this on Debian 12.6 Stable running python 3.11 and another machine running Fedora and python 3.12. From commenting out all smart playlists and adding them back until the error reappeared, I've found whenever any smartplaylist query includes "playlist:x", "beet splupdate" fails with the python error "TypeError: unhashable type: 'list'". (I'm using a minimal config and a test playlist that I've confirmed produce the same issue instead of my usual ones. The full config is >400 lines, mostly irrelevant. The verbose mode of playlist plugin will print out the full path to every item in every playlist, which led to a line of over 40,000 chars in the error output.) 'playlist' and 'smartplaylist' are the only enabled plugins. testplaylist.m3u is a playlist. smartplaylist is configured with 1 query (query: playlist:"testplaylist"). Running this command in verbose (
-vv
) mode:Led to this problem:
Here's a link to the music files that trigger the bug (if relevant):
Setup
My configuration (output of
beet config
) is (the minimal config that produces the issue above):I haven't tested this much but I have a potential solution. Based on the TypeError pointing to self.pattern on line 185 in 'beets/dbcore/query.py' it seemed like changing self.pattern into another type would fix it. In 'beets/dbcore/query.py', on line 184 in class FieldQuery, I changed:
to:
After this, there is no error and it produces the playlists (but I haven't really looked at all at query.py to know if this could cause problems with something else).