beetbox / mediafile

elegant audio file tagging
http://mediafile.readthedocs.io/
MIT License
97 stars 24 forks source link

List fields don't return None if the tag doesn't exist #63

Closed jtpavlock closed 1 year ago

jtpavlock commented 1 year ago

If a list tag does not exist, it returns an empty list rather than None, but if a non-list tag does not exist, None is returned.

I believe non-existent list tags should also return None so that this behavior is consistent.

sampsyo commented 1 year ago

That's an interesting suggestion! Which tags are you thinking of that produce None when the field is missing? We actually try to avoid that in most cases—the idea is to simplify client code so it doesn't need to constantly check the type of every field. For example, I believe artist is '', not None, when the underlying metadata is missing.

This design decision is certainly a trade-off. The simpler client code comes at the cost of not being able to distinguish the existence of tags.

jtpavlock commented 1 year ago

Which tags are you thinking of that produce None when the field is missing?

Referencing #38 and #39, I thought this was the desired behavior if a tag is missing altogether.

sampsyo commented 1 year ago

Ah, you're totally right; I was thinking of the old behavior before we started making this change. (And also what we do at the beets layer, which is to coalesce missing values into default values.) In that case, this issue makes sense to me!