From 0b315cf8c806273b5aa45e5755209b6970ba9edc Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Fri, 25 Apr 2014 13:50:03 -0700 Subject: [PATCH] Document/check non-emptiness in add_album --- beets/library.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/beets/library.py b/beets/library.py index bb10f7392..4bdc321cb 100644 --- a/beets/library.py +++ b/beets/library.py @@ -985,10 +985,15 @@ class Library(dbcore.Database): return obj.id def add_album(self, items): - """Create a new album consisting of a list of items. The items - are added to the database if they don't yet have an ID. Return a - new :class:`Album` object. + """Create a new album consisting of a list of items. + + The items are added to the database if they don't yet have an + ID. Return a new :class:`Album` object. The list items must not + be empty. """ + if not items: + raise ValueError(u'need at least one item') + # Create the album structure using metadata from the first item. values = dict((key, items[0][key]) for key in Album.item_keys) album = Album(self, **values)