File objects with no tags cast to boolean as false
sparr opened this issue · comments
True if mutagen.File("foo.ogg") else False
This will evaluate to False
if foo.ogg contains no id3 tags. I believe this is because the mutagen file types do not have a __bool__
method, so the implicit boolean cast falls back on __len__
which ends up referring to the number of keys in the DictProxy for the file's id3 tags.
While I could work around this by explicitly checking for None
vs a file type instance, I think it would be reasonable to expect the type to cast to True
when it has successfully loaded a file.