From 4a6584a60a030f2f7e8c25b3a3916090b6e7223a Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 4 Feb 2023 09:27:31 -0800 Subject: [PATCH] Only allow 1-sized Libraries --- masque/library.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/masque/library.py b/masque/library.py index 0114d49..afce0f4 100644 --- a/masque/library.py +++ b/masque/library.py @@ -587,12 +587,15 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta) self.add(tree.library, rename_theirs=rename_theirs) return name - def __lshift__(self, other: Mapping[str, 'Pattern']) -> Optional[str]: + def __lshift__(self, other: Mapping[str, 'Pattern']) -> str: if isinstance(other, Tree): return self.add_tree(other) # Add library and return topcell name - name = next(other.keys()) if len(other) == 1 else None # If only one name, return it - lib.add(other) + if len(other) != 1: + raise LibraryError('Received a non-Tree library containing multiple cells') + + name = next(iter(other)) + self.add(other) return name def dedup(