Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty fields returning None #38

Closed
jtpavlock opened this issue Sep 8, 2020 · 1 comment · Fixed by #39
Closed

Empty fields returning None #38

jtpavlock opened this issue Sep 8, 2020 · 1 comment · Fixed by #39

Comments

@jtpavlock
Copy link
Contributor

Going off the docs.

MediaFile attempts to always return a usable value (i.e., it never returns None or throws an exception when a tag is accessed). If a tag is not present, an empty and false value of the appropriate type – such as zero or the empty string – is returned.

>>> f = MediaFile('tests/resources/audio_files/empty.mp3')
>>> print(f.title)
None

Is this going against expected behavior or maybe the docs are out of date?

@sampsyo
Copy link
Member

sampsyo commented Sep 8, 2020

That's a good point—this did change in beetbox/beets#660, and it also looks like the docstring for _safe_cast is out of date. Fields can now return None if the tag is missing altogether, which is useful for some clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants