Apply suggestions from code review

I was wondering if there was a specific reason for `if val` but good to hear we can safely use `len(val == 0`

Co-authored-by: compilade <git@compilade.net>
This commit is contained in:
Brian 2024-07-31 00:29:33 +10:00 committed by GitHub
parent 02665ba32e
commit e96d263407
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -312,7 +312,7 @@ class GGUFWriter:
self.add_key_value(key, val, GGUFValueType.STRING)
def add_array(self, key: str, val: Sequence[Any]) -> None:
if not val:
if len(val) == 0:
return
self.add_key_value(key, val, GGUFValueType.ARRAY)
@ -852,7 +852,7 @@ class GGUFWriter:
if not isinstance(val, Sequence):
raise ValueError("Invalid GGUF metadata array, expecting sequence")
if not val:
if len(val) == 0:
raise ValueError("Invalid GGUF metadata array. Empty array")
if isinstance(val, bytes):